Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-05-31 17:35:38
Exec Total Coverage
Lines: 8585 12287 69.9%
Functions: 74 106 69.8%
Branches: 5446 10028 54.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #include <stdio.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "font.h"
36 #include "zc/zc_custom.h"
37 #include "sfx.h"
38 #include "md5.h"
39 #include "zc/ffscript.h"
40 #include "particles.h"
41 #include "dialog/alert.h"
42
43 #ifdef __EMSCRIPTEN__
44 #include "base/emscripten_utils.h"
45 #endif
46
47 //FFScript FFCore;
48 extern FFScript FFCore;
49 extern ZModule zcm;
50 extern zcmodule moduledata;
51 extern uint8_t __isZQuest;
52 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
53 extern particle_list particles;
54 extern void setZScriptVersion(int32_t s_version);
55 //FFSCript FFEngine;
56
57 int32_t temp_ffscript_version = 0;
58 static bool read_ext_zinfo = false, read_zinfo = false;
59 static bool loadquest_report = false;
60 static char const* loading_qst_name = NULL;
61 static byte loading_qst_num = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 // extern bool debug;
79 extern int32_t hero_animation_speed; //lower is faster animation
80 extern std::vector<mapscr> TheMaps;
81 extern zcmap *ZCMaps;
82 extern MsgStr *MsgStrings;
83 extern DoorComboSet *DoorComboSets;
84 extern dmap *DMaps;
85 extern newcombo *combobuf;
86 extern byte *colordata;
87 //extern byte *tilebuf;
88 extern tiledata *newtilebuf;
89 extern byte *trashbuf;
90 extern itemdata *itemsbuf;
91 extern wpndata *wpnsbuf;
92 extern comboclass *combo_class_buf;
93 extern guydata *guysbuf;
94 extern ZCHEATS zcheats;
95 extern zinitdata zinit;
96 extern char palnames[MAXLEVELS][17];
97 extern int32_t memrequested;
98 extern char *byte_conversion(int32_t number, int32_t format);
99 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
100 33 string zScript;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
33 std::map<int32_t, script_slot_data > ffcmap;
102 33 std::map<int32_t, script_slot_data > globalmap;
103 33 std::map<int32_t, script_slot_data > genericmap;
104 33 std::map<int32_t, script_slot_data > itemmap;
105 33 std::map<int32_t, script_slot_data > npcmap;
106 33 std::map<int32_t, script_slot_data > ewpnmap;
107 33 std::map<int32_t, script_slot_data > lwpnmap;
108 33 std::map<int32_t, script_slot_data > playermap;
109 33 std::map<int32_t, script_slot_data > dmapmap;
110 33 std::map<int32_t, script_slot_data > screenmap;
111 33 std::map<int32_t, script_slot_data > itemspritemap;
112 33 std::map<int32_t, script_slot_data > comboscriptmap;
113 void free_newtilebuf();
114 bool combosread=false;
115 bool mapsread=false;
116 bool fixffcs=false;
117 bool fixpolsvoice=false;
118
119
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
120
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
121
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
122
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
123
124 char qstdat_string[2048] = { 0 };
125
126 static zinfo* load_tmp_zi = NULL;
127
128 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
129 const byte clavio[9]={97,109,111,110,103,117,115,0};
130
131 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
132 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
133
134 extern combo_alias combo_aliases[MAXCOMBOALIASES];
135 extern combo_pool combo_pools[MAXCOMBOPOOLS];
136 const char *qst_error[] =
137 {
138 "OK","File not found","Invalid quest file",
139 "Version not supported","Obsolete version",
140 "Missing new data" , /* but let it pass in ZQuest */
141 "Internal error occurred", "Invalid password",
142 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
143 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
144 };
145
146 //for legacy quests -DD
147 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
148 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
149 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
150 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
151 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
152 };
153
154 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
155
156
157 void delete_combo_aliases()
158 {
159 for(int32_t j(0); j<256; j++)
160 {
161 if(combo_aliases[j].combos != NULL)
162 {
163 delete[] combo_aliases[j].combos;
164 combo_aliases[j].combos=NULL;
165 }
166
167 if(combo_aliases[j].csets != NULL)
168 {
169 delete[] combo_aliases[j].csets;
170 combo_aliases[j].csets=NULL;
171 }
172 }
173
174 }
175
176 char *byte_conversion(int32_t number, int32_t format)
177 {
178 static char num_str[40];
179
180 if(format==-1) //auto
181 {
182 format=1; //bytes
183
184 if(number>1024)
185 {
186 format=2; //kilobytes
187 }
188
189 if(number>1024*1024)
190 {
191 format=3; //megabytes
192 }
193
194 if(number>1024*1024*1024)
195 {
196 format=4; //gigabytes (dude, what are you doing?)
197 }
198 }
199
200 switch(format)
201 {
202 case 1: //bytes
203 sprintf(num_str,"%db",number);
204 break;
205
206 case 2: //kilobytes
207 sprintf(num_str,"%.2fk",float(number)/1024);
208 break;
209
210 case 3: //megabytes
211 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
212 break;
213
214 case 4: //gigabytes
215 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
216 break;
217
218 default:
219 exit(1);
220 break;
221 }
222
223 return num_str;
224 }
225
226 462 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
227 {
228 static char num_str1[40];
229 static char num_str2[40];
230 static char num_str[80];
231
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format1==-1) //auto
233 {
234 462 format1=1; //bytes
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number1>1024)
237 {
238 462 format1=2; //kilobytes
239 462 }
240
241
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 132 times.
462 if(number1>1024*1024)
242 {
243 132 format1=3; //megabytes
244 132 }
245
246
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number1>1024*1024*1024)
247 {
248 format1=4; //gigabytes (dude, what are you doing?)
249 }
250 462 }
251
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format2==-1) //auto
253 {
254 462 format2=1; //bytes
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number2>1024)
257 {
258 462 format2=2; //kilobytes
259 462 }
260
261
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 429 times.
462 if(number2>1024*1024)
262 {
263 429 format2=3; //megabytes
264 429 }
265
266
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number2>1024*1024*1024)
267 {
268 format2=4; //gigabytes (dude, what are you doing?)
269 }
270 462 }
271
272
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
462 switch(format1)
273 {
274 case 1: //bytes
275 sprintf(num_str1,"%db",number1);
276 break;
277
278 case 2: //kilobytes
279 330 sprintf(num_str1,"%.2fk",float(number1)/1024);
280 330 break;
281
282 case 3: //megabytes
283 132 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
284 132 break;
285
286 case 4: //gigabytes
287 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
288 break;
289
290 default:
291 exit(1);
292 break;
293 }
294
295
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 429 times.
✗ Branch 4 not taken.
462 switch(format2)
296 {
297 case 1: //bytes
298 sprintf(num_str2,"%db",number2);
299 break;
300
301 case 2: //kilobytes
302 33 sprintf(num_str2,"%.2fk",float(number2)/1024);
303 33 break;
304
305 case 3: //megabytes
306 429 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
307 429 break;
308
309 case 4: //gigabytes
310 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
311 break;
312
313 default:
314 exit(1);
315 break;
316 }
317
318 462 sprintf(num_str, "%s/%s", num_str1, num_str2);
319 462 return num_str;
320 }
321
322 char *ordinal(int32_t num)
323 {
324 static const char *ending[4] = {"st","nd","rd","th"};
325 static char ord_str[8];
326
327 char *end;
328 int32_t t=(num%100)/10;
329 int32_t n=num%10;
330
331 if(n>=1 && n<4 && t!=1)
332 end = (char *)ending[n-1];
333 else
334 end = (char *)ending[3];
335
336 sprintf(ord_str,"%d%s",num%10000,end);
337 return ord_str;
338 }
339
340 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
341 {
342 int32_t ret;
343 *version=0;
344 *build=0;
345 byte temp_map_count=map_count;
346 byte temp_midi_flags[MIDIFLAGS_SIZE];
347 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
348
349 zquestheader tempheader;
350
351 if(!f)
352 {
353 return qe_invalid;
354 }
355
356 ret=readheader(f, &tempheader, true);
357
358 if(ret)
359 {
360 return ret;
361 }
362
363 map_count=temp_map_count;
364 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
365 *version=tempheader.zelda_version;
366 *build=tempheader.build;
367 return 0;
368 }
369
370
371 bool find_section(PACKFILE *f, int32_t section_id_requested)
372 {
373
374 if(!f)
375 {
376 return false;
377 }
378
379 int32_t section_id_read;
380 bool catchup=false;
381 word dummy;
382 byte tempbyte;
383 char tempbuf[65536];
384
385
386 switch(section_id_requested)
387 {
388 case ID_RULES:
389 case ID_STRINGS:
390 case ID_MISC:
391 case ID_TILES:
392 case ID_COMBOS:
393 case ID_CSETS:
394 case ID_MAPS:
395 case ID_DMAPS:
396 case ID_DOORS:
397 case ID_ITEMS:
398 case ID_WEAPONS:
399 case ID_COLORS:
400 case ID_ICONS:
401 case ID_INITDATA:
402 case ID_GUYS:
403 case ID_MIDIS:
404 case ID_CHEATS:
405 break;
406
407 default:
408 al_trace("Bad section requested!\n");
409 return false;
410 break;
411 }
412
413 dword section_size;
414
415 //section id
416 if(!p_mgetl(&section_id_read,f,true))
417 {
418 return false;
419 }
420
421 while(!pack_feof(f))
422 {
423 switch(section_id_read)
424 {
425 case ID_RULES:
426 case ID_STRINGS:
427 case ID_MISC:
428 case ID_TILES:
429 case ID_COMBOS:
430 case ID_CSETS:
431 case ID_MAPS:
432 case ID_DMAPS:
433 case ID_DOORS:
434 case ID_ITEMS:
435 case ID_WEAPONS:
436 case ID_COLORS:
437 case ID_ICONS:
438 case ID_INITDATA:
439 case ID_GUYS:
440 case ID_MIDIS:
441 case ID_CHEATS:
442 catchup=false;
443 break;
444
445 default:
446 break;
447 }
448
449
450 while(catchup)
451 {
452 //section id
453 section_id_read=(section_id_read<<8);
454
455 if(!p_getc(&tempbyte,f,true))
456 {
457 return false;
458 }
459
460 section_id_read+=tempbyte;
461 }
462
463 if(section_id_read==section_id_requested)
464 {
465 return true;
466 }
467 else
468 {
469 //section version info
470 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 if(!p_igetw(&dummy,f,true))
476 {
477 return false;
478 }
479
480 //section size
481 if(!p_igetl(&section_size,f,true))
482 {
483 return false;
484 }
485
486 //pack_fseek(f, section_size);
487 while(section_size>65535)
488 {
489 pfread(tempbuf,65535,f,true);
490 tempbuf[65535]=0;
491 section_size-=65535;
492 }
493
494 if(section_size>0)
495 {
496 pfread(tempbuf,section_size,f,true);
497 tempbuf[section_size]=0;
498 }
499 }
500
501 //section id
502 if(!p_mgetl(&section_id_read,f,true))
503 {
504 return false;
505 }
506 }
507
508 return false;
509 }
510
511
512
513
514
515 bool valid_zqt(PACKFILE *f)
516 {
517
518 //word tiles_used;
519 //word combos_used;
520 //open the file
521 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
522 if(!f)
523 return false;
524
525 //for now, everything else is valid
526 return true;
527
528 /*int16_t version;
529 byte build;
530
531 //read the version and make sure it worked
532 if(!p_igetw(&version,f,true))
533 {
534 goto error;
535 }
536
537 //read the build and make sure it worked
538 if(!p_getc(&build,f,true))
539 goto error;
540
541 //read the tile info and make sure it worked
542 if(!p_igetw(&tiles_used,f,true))
543 {
544 goto error;
545 }
546
547 for (int32_t i=0; i<tiles_used; i++)
548 {
549 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
550 {
551 goto error;
552 }
553 }
554
555 //read the combo info and make sure it worked
556 if(!p_igetw(&combos_used,f,true))
557 {
558 goto error;
559 }
560 for (int32_t i=0; i<combos_used; i++)
561 {
562 if(!pfread(trashbuf,sizeof(newcombo),f,true))
563 {
564 goto error;
565 }
566 }
567
568 //read the palette info and make sure it worked
569 for (int32_t i=0; i<48; i++)
570 {
571 if(!pfread(trashbuf,newpdTOTAL,f,true))
572 {
573 goto error;
574 }
575 }
576 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
577 {
578 goto error;
579 }
580 for (int32_t i=0; i<MAXLEVELS; i++)
581 {
582 if(!pfread(trashbuf,PALNAMESIZE,f,true))
583 {
584 goto error;
585 }
586 }
587
588 //read the sprite info and make sure it worked
589 for (int32_t i=0; i<MAXITEMS; i++)
590 {
591 if(!pfread(trashbuf,sizeof(itemdata),f,true))
592 {
593 goto error;
594 }
595 }
596
597 for (int32_t i=0; i<MAXWPNS; i++)
598 {
599 if(!pfread(trashbuf,sizeof(wpndata),f,true))
600 {
601 goto error;
602 }
603 }
604
605 //read the triforce pieces info and make sure it worked
606 for (int32_t i=0; i<8; ++i)
607 {
608 if(!p_getc(&trashbuf,f,true))
609 {
610 goto error;
611 }
612 }
613
614
615
616 //read the game icons info and make sure it worked
617 for (int32_t i=0; i<4; ++i)
618 {
619 if(!p_igetw(&trashbuf,f,true))
620 {
621 goto error;
622 }
623 }
624
625 //read the misc colors info and map styles info and make sure it worked
626 if(!pfread(trashbuf,sizeof(zcolors),f,true))
627 {
628 goto error;
629 }
630
631 //read the template screens and make sure it worked
632 byte num_maps;
633 if(!p_getc(&num_maps,f,true))
634 {
635 goto error;
636 }
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f,true))
640 {
641 goto error;
642 }
643 }
644 if (num_maps>1) //dungeon templates
645 {
646 for (int32_t i=0; i<TEMPLATES; i++)
647 {
648 if(!pfread(trashbuf,sizeof(mapscr),f,true))
649 {
650 goto error;
651 }
652 }
653 }
654
655 //yay! it worked! close the file and say everything was ok.
656 pack_fclose(f);
657 return true;
658
659 error:
660 pack_fclose(f);
661 return false;*/
662 }
663
664 bool valid_zqt(const char *filename)
665 {
666 PACKFILE *f=NULL;
667 bool isvalid;
668 int32_t error;
669 f=open_quest_file(&error, filename, false);
670
671 if(!f)
672 {
673 // setPackfilePassword(NULL);
674 return false;
675 }
676
677 isvalid=valid_zqt(f);
678
679 clear_quest_tmpfile();
680 pack_fclose(f);
681
682 // setPackfilePassword(NULL);
683 return isvalid;
684 }
685
686 33 static std::string tmp_file_name;
687 216 void clear_quest_tmpfile()
688 {
689
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 7 times.
216 if(tmp_file_name.size())
690 {
691
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(exists(tmp_file_name.c_str()))
692 7 delete_file(tmp_file_name.c_str());
693 7 tmp_file_name.clear();
694 7 }
695 216 }
696 /*
697 .qst file history
698
699 .qst files have always been compressed using allegro's packfiles.
700
701 At some point, an encoding layer was added. The two layers look like this:
702
703 1) The top layer is from us. See decode_file_007.
704 [0-24] Preamble "Zelda Classic Quest File"
705 [25-28] Initial decoding seed value.
706 [29-X] Allegro-encoded payload (AKA "packed" file)
707 [last 4] Checksum
708
709 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
710 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
711 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
712 The oldest quests skip the password part.
713
714 Simply, the job of this function is to peel away the top layer.
715
716 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
717 in opening and saving files. There is no version field, so they decryption key is
718 found via trial-by-error (very slow!)
719
720 There are other file types of interest:
721 - .zqt: quest template files, skips top-layer encryption pass
722 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
723 - .qu?: same as above. automated backup files
724 - .qb?: same as above. automated backup files
725 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
726
727 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
728 files are now "slh!.AG ZC Enhanced Quest File".
729 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
730 */
731 108 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
732 {
733 #ifdef __EMSCRIPTEN__
734 if (em_is_lazy_file(filename))
735 {
736 em_fetch_file(filename);
737 }
738 #endif
739 108 clear_quest_tmpfile();
740 // Note: although this is primarily for loading .qst files, it can also handle all of the
741 // file types mentioned in the comment above. No need to be told if the file being loaded
742 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
743 108 bool top_layer_compressed = false;
744 108 bool compressed = false;
745 108 bool encrypted = false;
746
747 // Input files may or may not include a top layer, which may or may not be compressed.
748 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
749 // with an allegro packfile password (longtan).
750 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
751 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
752 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
753
754 108 bool id_came_from_compressed_file = false;
755 108 const char* packfile_password = "";
756 char id[31];
757 108 id[0] = '\0';
758 108 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
759
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 10 times.
108 if (!pf)
760 10 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
761
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3 times.
108 if (pf)
762 {
763 105 id_came_from_compressed_file = true;
764
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if (!pack_fread(id, sizeof(id), pf))
765 {
766 pack_fclose(pf);
767 Z_message("Unable to read header string\n");
768 return nullptr;
769 }
770 105 pack_fclose(pf);
771 105 }
772 else
773 {
774 3 FILE* f = fopen(filename, "rb");
775
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
776 {
777 *open_error=qe_notfound;
778 return nullptr;
779 }
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id), f))
781 {
782 fclose(f);
783 Z_message("Unable to read header string\n");
784 return nullptr;
785 }
786 3 fclose(f);
787 }
788
789
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
108 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
790 {
791 // The given file is already just the bottom layer - nothing more to do.
792 // There's no way to rewind a packfile, so just open it again.
793 98 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
794 }
795
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7 times.
10 else if (strstr(id, ENC_STR))
796 {
797 3 top_layer_compressed = id_came_from_compressed_file;
798 3 compressed = true;
799 3 encrypted = true;
800 3 }
801
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
802 {
803 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
804 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
805
806 char tmpfilename[L_tmpnam];
807 7 std::tmpnam(tmpfilename);
808 7 FILE* tf = fopen(tmpfilename, "wb");
809 7 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
810
811 int c;
812
2/2
✓ Branch 0 taken 21302330 times.
✓ Branch 1 taken 7 times.
21302337 while ((c = pack_getc(pf)) != EOF)
813 {
814 21302330 fputc(c, tf);
815 }
816 7 fclose(tf);
817 7 pack_fclose(pf);
818
819 7 tmp_file_name = tmpfilename; //store so it can be cleaned up later
820
821 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
822 // We should put qsu in the dat file, or use a separate .qst file for new qst.
823 7 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
824 }
825 else
826 {
827 // Unexpected, this is going to fail some header check later.
828 }
829
830 // Everything below here is legacy code - recently saved quest files will have
831 // returned by now.
832
833 char tmpfilename[L_tmpnam];
834 3 temp_name(tmpfilename);
835 char percent_done[30];
836 3 int32_t current_method=0;
837
838 PACKFILE *f;
839 3 const char *passwd= encrypted ? datapwd : "";
840
841 // oldquest flag is set when an unencrypted qst file is suspected.
842 3 bool oldquest = false;
843 int32_t ret;
844
845
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(show_progress)
846 {
847 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
848 }
849
850 3 box_out("Loading Quest: ");
851 3 al_trace("Trying to do strncasecmp() when loading a quest\n");
852 3 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
853 3 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
854
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
855 {
856 3 box_out(filename);
857 3 }
858 else
859 {
860 box_out("new quest"); // Or whatever
861 }
862 3 box_out("...");
863 3 box_eol();
864 3 box_eol();
865
866
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
867 {
868 3 box_out("Decrypting...");
869 3 box_save_x();
870 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
871
872
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
873 {
874 switch(ret)
875 {
876 case 1:
877 box_out("error.");
878 box_eol();
879 box_end(true);
880 *open_error=qe_notfound;
881 return NULL;
882
883 case 2:
884 box_out("error.");
885 box_eol();
886 box_end(true);
887 *open_error=qe_internal;
888 return NULL;
889 // be sure not to delete tmpfilename now...
890 }
891
892 if(ret==5) //old encryption?
893 {
894 current_method++;
895 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
896 box_out(percent_done);
897 box_load_x();
898 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
899 }
900
901 if(ret==5) //old encryption?
902 {
903 current_method++;
904 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
905 box_out(percent_done);
906 box_load_x();
907 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
908 }
909
910 if(ret==5) //old encryption?
911 {
912 current_method++;
913 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
914 box_out(percent_done);
915 box_load_x();
916 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
917 }
918
919 if(ret==5) //old encryption?
920 {
921 current_method++;
922 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
923 box_out(percent_done);
924 box_load_x();
925 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
926 }
927
928 if(ret)
929 {
930 oldquest = true;
931 passwd="";
932 }
933 }
934
935 3 box_out("okay.");
936 3 box_eol();
937 3 }
938 else
939 {
940 oldquest = true;
941 }
942
943 3 box_out("Opening...");
944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
945
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
946 {
947 if((compressed==1)&&(errno==EDOM))
948 {
949 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
950 }
951
952 if(!f)
953 {
954 if(!oldquest)
955 {
956 delete_file(tmpfilename);
957 }
958 box_out("error.");
959 box_eol();
960 box_end(true);
961 *open_error=qe_invalid;
962 return NULL;
963 }
964 }
965
966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
967 {
968 3 delete_file(tmpfilename);
969 3 }
970
971 3 box_out("okay.");
972 3 box_eol();
973
974 3 return f;
975 108 }
976
977 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
978 {
979 char *filename;
980 PACKFILE *f=NULL;
981 int32_t open_error=0;
982
983 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
984 strcat(qstdat_string,"#NESQST_NEW_QST");
985 if(Header->templatepath[0]==0)
986 {
987 filename=(char *)malloc(2048);
988 strcpy(filename, qstdat_string);
989 }
990 else
991 {
992 // TODO: should be safe to remove this, no one seems to use custom quest templates.
993 filename=Header->templatepath;
994 }
995
996 f=open_quest_file(&open_error, filename, false);
997
998 if(Header->templatepath[0]==0)
999 {
1000 free(filename);
1001 }
1002
1003 if(!f)
1004 {
1005 return NULL;
1006 }
1007
1008 if(validate)
1009 {
1010 if(!valid_zqt(f))
1011 {
1012 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1013 pack_fclose(f);
1014 clear_quest_tmpfile();
1015 return NULL;
1016 }
1017 }
1018
1019 return f;
1020 }
1021
1022 33 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1023 {
1024 // We absolutely do not support loading from a template file to initialize data outside the editor.
1025 // TODO: move this code into zq/
1026
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (get_app_id() != App::zquest) return false;
1027
1028 combosread=false;
1029 mapsread=false;
1030 fixffcs=false;
1031
1032 switch(section_id)
1033 {
1034 case ID_RULES:
1035 case ID_STRINGS:
1036 case ID_MISC:
1037 case ID_TILES:
1038 case ID_COMBOS:
1039 case ID_CSETS:
1040 case ID_MAPS:
1041 case ID_DMAPS:
1042 case ID_DOORS:
1043 case ID_ITEMS:
1044 case ID_WEAPONS:
1045 case ID_COLORS:
1046 case ID_ICONS:
1047 case ID_INITDATA:
1048 case ID_GUYS:
1049 case ID_MIDIS:
1050 case ID_CHEATS:
1051 case ID_ITEMDROPSETS:
1052 case ID_FAVORITES:
1053 break;
1054
1055 default:
1056 return false;
1057 break;
1058 }
1059
1060 int32_t ret;
1061 word version, build;
1062 PACKFILE *f=NULL;
1063
1064 char deletefilename[1024];
1065 deletefilename[0]=0;
1066
1067 //why is this here?
1068 /*
1069 if(colordata==NULL)
1070 return false;
1071 */
1072
1073 //setPackfilePassword(datapwd);
1074 f=open_quest_template(Header, deletefilename, validate);
1075
1076 if(!f) //no file, nothing to delete
1077 {
1078 // setPackfilePassword(NULL);
1079 return false;
1080 }
1081
1082 ret=get_version_and_build(f, &version, &build);
1083
1084 if(ret||(version==0))
1085 {
1086 pack_fclose(f);
1087 clear_quest_tmpfile();
1088
1089 if(deletefilename[0])
1090 {
1091 delete_file(deletefilename);
1092 }
1093
1094 // setPackfilePassword(NULL);
1095 return false;
1096 }
1097
1098 if(!find_section(f, section_id))
1099 {
1100 al_trace("Can't find section!\n");
1101 pack_fclose(f);
1102 clear_quest_tmpfile();
1103
1104 if(deletefilename[0])
1105 {
1106 delete_file(deletefilename);
1107 }
1108
1109 //setPackfilePassword(NULL);
1110 return false;
1111 }
1112
1113 switch(section_id)
1114 {
1115 case ID_RULES:
1116 //rules
1117 ret=readrules(f, Header, true);
1118 break;
1119
1120 case ID_STRINGS:
1121 //strings
1122 ret=readstrings(f, Header, true);
1123 break;
1124
1125 case ID_MISC:
1126 //misc data
1127 ret=readmisc(f, Header, Misc, true);
1128 break;
1129
1130 case ID_TILES:
1131 //tiles
1132 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1133 break;
1134
1135 case ID_COMBOS:
1136 //combos
1137 clear_combos();
1138 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1139 combosread=true;
1140 break;
1141
1142 case ID_COMBOALIASES:
1143 //combos
1144 ret=readcomboaliases(f, Header, version, build, true);
1145 break;
1146
1147 case ID_CSETS:
1148 //color data
1149 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1150 break;
1151
1152 case ID_MAPS:
1153 //maps
1154 ret=readmaps(f, Header, true);
1155 mapsread=true;
1156 break;
1157
1158 case ID_DMAPS:
1159 //dmaps
1160 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1161 break;
1162
1163 case ID_DOORS:
1164 //door combo sets
1165 ret=readdoorcombosets(f, Header, true);
1166 break;
1167
1168 case ID_ITEMS:
1169 //items
1170 ret=readitems(f, version, build, true);
1171 break;
1172
1173 case ID_WEAPONS:
1174 //weapons
1175 ret=readweapons(f, Header, true);
1176 break;
1177
1178 case ID_COLORS:
1179 //misc. colors
1180 ret=readmisccolors(f, Header, Misc, true);
1181 break;
1182
1183 case ID_ICONS:
1184 //game icons
1185 ret=readgameicons(f, Header, Misc, true);
1186 break;
1187
1188 case ID_INITDATA:
1189 //initialization data
1190 ret=readinitdata(f, Header, true);
1191 break;
1192
1193 case ID_GUYS:
1194 //guys
1195 ret=readguys(f, Header, true);
1196 break;
1197
1198 case ID_MIDIS:
1199 //midis
1200 ret=readtunes(f, Header, tunes, true);
1201 break;
1202
1203 case ID_CHEATS:
1204 //cheat codes
1205 ret=readcheatcodes(f, Header, true);
1206 break;
1207
1208 case ID_ITEMDROPSETS:
1209 //item drop sets
1210 // Why is this one commented out?
1211 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1212 break;
1213
1214 case ID_FAVORITES:
1215 // favorite combos and aliases
1216 ret=readfavorites(f, version, build, true);
1217 break;
1218
1219 default:
1220 ret=-1;
1221 break;
1222 }
1223
1224 pack_fclose(f);
1225 clear_quest_tmpfile();
1226
1227 if(deletefilename[0])
1228 {
1229 delete_file(deletefilename);
1230 }
1231
1232 //setPackfilePassword(NULL);
1233 if(!ret)
1234 {
1235 return true;
1236 }
1237
1238 return false;
1239 33 }
1240
1241 bool init_tiles(bool validate, zquestheader *Header)
1242 {
1243 return init_section(Header, ID_TILES, NULL, NULL, validate);
1244 }
1245
1246 bool init_combos(bool validate, zquestheader *Header)
1247 {
1248 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1249 }
1250
1251 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1252 {
1253 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1254 }
1255
1256 108 void init_spritelists()
1257 {
1258
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
108 if(FFCore.quest_format[vZelda] < 0x255)
1259 {
1260 85 guys.setMax(255);
1261 85 items.setMax(255);
1262 85 Ewpns.setMax(255);
1263 85 Lwpns.setMax(255);
1264 85 Sitems.setMax(255);
1265 85 chainlinks.setMax(255);
1266 85 decorations.setMax(255);
1267 85 particles.setMax(255);
1268 85 }
1269 else
1270 {
1271 23 guys.setMax(255);
1272 23 items.setMax(255);
1273 23 Ewpns.setMax(255);
1274 23 Lwpns.setMax(255);
1275 23 Sitems.setMax(255);
1276 23 chainlinks.setMax(255);
1277 23 decorations.setMax(255);
1278 23 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1279 }
1280 108 }
1281
1282 33 bool reset_items(bool validate, zquestheader *Header)
1283 {
1284 33 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1285
1286
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 33 times.
8481 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1287
1288 33 return ret;
1289 }
1290
1291 bool reset_guys()
1292 {
1293 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1294 init_guys(V_GUYS);
1295 return true;
1296 }
1297
1298 bool reset_wpns(bool validate, zquestheader *Header)
1299 {
1300 bool ret = true;
1301 if (get_app_id() == App::zquest)
1302 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1303
1304 for(int32_t i=0; i<WPNCNT; i++)
1305 reset_weaponname(i);
1306
1307 return ret;
1308 }
1309
1310 bool reset_mapstyles(bool validate, miscQdata *Misc)
1311 {
1312 Misc->colors.blueframe_tile = 20044;
1313 Misc->colors.blueframe_cset = 0;
1314 Misc->colors.triforce_tile = 23461;
1315 Misc->colors.triforce_cset = 1;
1316 Misc->colors.triframe_tile = 18752;
1317 Misc->colors.triframe_cset = 1;
1318 Misc->colors.overworld_map_tile = 16990;
1319 Misc->colors.overworld_map_cset = 2;
1320 Misc->colors.HCpieces_tile = 21160;
1321 Misc->colors.HCpieces_cset = 8;
1322 Misc->colors.dungeon_map_tile = 19651;
1323 Misc->colors.dungeon_map_cset = 8;
1324 return true;
1325 }
1326
1327 33 int32_t get_qst_buffers()
1328 {
1329 33 memrequested+=(sizeof(mapscr)*MAPSCRS);
1330 33 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1331 33 TheMaps.resize(MAPSCRS);
1332
1333
2/2
✓ Branch 0 taken 4488 times.
✓ Branch 1 taken 33 times.
4521 for(int32_t i(0); i<MAPSCRS; i++)
1334 4488 TheMaps[i].zero_memory();
1335
1336 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1337 33 Z_message("OK\n"); // Allocating map buffer...
1338
1339 33 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1340 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1341
1342
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1343 return 0;
1344
1345 33 Z_message("OK\n");
1346
1347 // Allocating space for all 65535 strings uses up 10.62MB...
1348 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1349 // (Shoelace's "Hero of Dreams" uses 1415.)
1350 // So let's be a bit generous and allow 4096 initially.
1351 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1352 // I tested it and it worked without flaw on 6/6/11. - L.
1353 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1354 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1355 // See https://discord.com/channels/876899628556091432/992984989073416242
1356 33 msg_strings_size = 8192;
1357 33 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1358 33 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1359
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 MsgStrings = new MsgStr[msg_strings_size];
1361
1362 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1363
2/2
✓ Branch 0 taken 270336 times.
✓ Branch 1 taken 33 times.
270369 for(auto q = 0; q < msg_strings_size; ++q)
1364 {
1365 270336 MsgStrings[q].clear();
1366 270336 }
1367 33 Z_message("OK\n"); // Allocating string buffer...
1368
1369 33 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1370 33 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1371
1372
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1373 return 0;
1374
1375 33 Z_message("OK\n"); // Allocating door combo buffer...
1376
1377 33 memrequested+=(sizeof(dmap)*MAXDMAPS);
1378 33 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1379
1380
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1381 return 0;
1382
1383 33 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1384 33 Z_message("OK\n"); // Allocating dmap buffer...
1385
1386 33 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1387 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1388
1389
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1390 return 0;
1391
1392 33 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1393 33 Z_message("OK\n"); // Allocating combo buffer...
1394
1395 33 memrequested+=(psTOTAL255);
1396 33 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1397
1398
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1399 return 0;
1400
1401 33 Z_message("OK\n"); // Allocating color data buffer...
1402
1403 33 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1404 33 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1405
1406 33 free_newtilebuf();
1407
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1408 return 0;
1409
1410 33 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1411 //Z_message("Performed memset on tiles\n");
1412 33 clear_tiles(newtilebuf);
1413 //Z_message("Performed clear_tiles()\n");
1414 33 Z_message("OK\n"); // Allocating tile buffer...
1415
1416
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(is_zquest())
1417 {
1418 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1419 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1420
1421 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1422 return 0;
1423
1424 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1425 clear_tiles(grabtilebuf);
1426 Z_message("OK\n"); // Allocating tile grab buffer...
1427 }
1428
1429 33 memrequested+=(100000);
1430 33 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1431
1432
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((trashbuf=(byte*)malloc(100000))==NULL)
1433 return 0;
1434
1435 33 Z_message("OK\n"); // Allocating trash buffer...
1436
1437 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1438 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1439 // fixed by ensuring there's actually itemdata there.
1440 // If you change this, be sure to update del_qst_buffers, too.
1441
1442 33 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1443 33 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1444
1445
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1446 return 0;
1447
1448 33 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1449 33 itemsbuf++;
1450 33 Z_message("OK\n"); // Allocating item buffer...
1451
1452 33 memrequested+=(sizeof(wpndata)*MAXWPNS);
1453 33 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1454
1455
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1456 return 0;
1457
1458 33 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1459 33 Z_message("OK\n"); // Allocating weapon buffer...
1460
1461 33 memrequested+=(sizeof(guydata)*MAXGUYS);
1462 33 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1463
1464
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1465 return 0;
1466
1467 33 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1468 33 Z_message("OK\n"); // Allocating guy buffer...
1469
1470 33 memrequested+=(sizeof(comboclass)*cMAX);
1471 33 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1472
1473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1474 return 0;
1475
1476 33 Z_message("OK\n"); // Allocating combo class buffer...
1477
1478 33 return 1;
1479 33 }
1480
1481
1482 33 void free_newtilebuf()
1483 {
1484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(newtilebuf)
1485 {
1486 for(int32_t i=0; i<NEWMAXTILES; i++)
1487 if(newtilebuf[i].data)
1488 free(newtilebuf[i].data);
1489
1490 free(newtilebuf);
1491 newtilebuf = 0;
1492 }
1493 33 }
1494
1495 void free_grabtilebuf()
1496 {
1497 if(is_zquest())
1498 {
1499 if(grabtilebuf)
1500 {
1501 for(int32_t i=0; i<NEWMAXTILES; i++)
1502 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1503
1504 free(grabtilebuf);
1505 grabtilebuf = 0;
1506 }
1507 }
1508 }
1509
1510 void del_qst_buffers()
1511 {
1512 al_trace("Cleaning maps. \n");
1513
1514 if(ZCMaps) free(ZCMaps);
1515
1516 if(MsgStrings) delete[] MsgStrings;
1517
1518 if(DoorComboSets) free(DoorComboSets);
1519
1520 if(DMaps) free(DMaps);
1521
1522 if(combobuf) free(combobuf);
1523
1524 if(colordata) free(colordata);
1525
1526 al_trace("Cleaning tile buffers. \n");
1527 free_newtilebuf();
1528 free_grabtilebuf();
1529
1530 al_trace("Cleaning misc. \n");
1531
1532 if(trashbuf) free(trashbuf);
1533
1534 // See get_qst_buffers
1535 if(itemsbuf)
1536 {
1537 itemsbuf--;
1538 free(itemsbuf);
1539 }
1540
1541 if(wpnsbuf) free(wpnsbuf);
1542
1543 if(guysbuf) free(guysbuf);
1544
1545 if(combo_class_buf) free(combo_class_buf);
1546 }
1547
1548 4 bool init_palnames()
1549 {
1550 // if(palnames==NULL)
1551 // return false;
1552
1553
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1554 {
1555
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1556 {
1557 case 0:
1558 4 sprintf(palnames[x],"Overworld");
1559 4 break;
1560
1561 case 10:
1562 4 sprintf(palnames[x],"Caves");
1563 4 break;
1564
1565 case 11:
1566 4 sprintf(palnames[x],"Passageways");
1567 4 break;
1568
1569 default:
1570 2036 sprintf(palnames[x],"%c",0);
1571 2036 break;
1572 }
1573 2048 }
1574
1575 4 return true;
1576 }
1577
1578 21320 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1579 {
1580 void *p;
1581
1582
1/2
✓ Branch 0 taken 21320 times.
✗ Branch 1 not taken.
21320 p = _AL_MALLOC(MAX(size, alloc_size));
1583
1584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21320 times.
21320 if(!p)
1585 {
1586 return NULL;
1587 }
1588
1589
1/2
✓ Branch 0 taken 21320 times.
✗ Branch 1 not taken.
21320 if(!pfread(p,size,f,keepdata))
1590 {
1591 _AL_FREE(p);
1592 return NULL;
1593 }
1594
1595
1/2
✓ Branch 0 taken 21320 times.
✗ Branch 1 not taken.
21320 if(pack_ferror(f))
1596 {
1597 _AL_FREE(p);
1598 return NULL;
1599 }
1600
1601 21320 return p;
1602 21320 }
1603
1604 /* read_midi:
1605 * Reads MIDI data from a datafile (this is not the same thing as the
1606 * standard midi file format).
1607 */
1608
1609 1866 static MIDI *read_midi(PACKFILE *f, bool)
1610 {
1611 MIDI *m;
1612 int32_t c;
1613 1866 int16_t divisions=0;
1614 1866 int32_t len=0;
1615
1616 1866 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1617
1618
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!m)
1619 {
1620 return NULL;
1621 }
1622
1623
2/2
✓ Branch 0 taken 59712 times.
✓ Branch 1 taken 1866 times.
61578 for(c=0; c<MIDI_TRACKS; c++)
1624 {
1625 59712 m->track[c].len = 0;
1626 59712 m->track[c].data = NULL;
1627 59712 }
1628
1629 1866 p_mgetw(&divisions,f,true);
1630 1866 m->divisions=divisions;
1631
1632
2/2
✓ Branch 0 taken 59712 times.
✓ Branch 1 taken 1866 times.
61578 for(c=0; c<MIDI_TRACKS; c++)
1633 {
1634 59712 p_mgetl(&len,f,true);
1635 59712 m->track[c].len=len;
1636
1637
2/2
✓ Branch 0 taken 38392 times.
✓ Branch 1 taken 21320 times.
59712 if(m->track[c].len > 0)
1638 {
1639 21320 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1640
1641
1/2
✓ Branch 0 taken 21320 times.
✗ Branch 1 not taken.
21320 if(!m->track[c].data)
1642 {
1643 destroy_midi(m);
1644 return NULL;
1645 }
1646 21320 }
1647 59712 }
1648
1649 LOCK_DATA(m, sizeof(MIDI));
1650
1651
2/2
✓ Branch 0 taken 59712 times.
✓ Branch 1 taken 1866 times.
61578 for(c=0; c<MIDI_TRACKS; c++)
1652 {
1653
2/2
✓ Branch 0 taken 21320 times.
✓ Branch 1 taken 38392 times.
59712 if(m->track[c].data)
1654 {
1655 LOCK_DATA(m->track[c].data, m->track[c].len);
1656 21320 }
1657 59712 }
1658
1659 1866 return m;
1660 1866 }
1661
1662 void clear_combo(int32_t i)
1663 {
1664 combobuf[i].clear();
1665 }
1666
1667 void clear_combos()
1668 {
1669 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1670 clear_combo(tmpcounter);
1671 }
1672
1673 void pack_combos()
1674 {
1675 int32_t di = 0;
1676
1677 for(int32_t si=0; si<1024; si+=2)
1678 combobuf[di++] = combobuf[si];
1679
1680 for(; di<1024; di++)
1681 clear_combo(di);
1682 }
1683
1684 108 void reset_tunes(zctune *tune)
1685 {
1686
2/2
✓ Branch 0 taken 27216 times.
✓ Branch 1 taken 108 times.
27324 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1687 {
1688 27216 tune[i].reset();
1689 27216 }
1690 108 }
1691
1692
1693 /*void reset_midi(zcmidi_ *m)
1694 {
1695 m->title[0]=0;
1696 m->loop=1;
1697 m->volume=144;
1698 m->start=0;
1699 m->loop_start=-1;
1700 m->loop_end=-1;
1701 if(m->midi)
1702 {
1703 destroy_midi(m->midi);
1704 }
1705 m->midi=NULL;
1706 }
1707
1708
1709 void reset_midis(zcmidi_ *m)
1710 {
1711 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1712 {
1713 reset_midi(m+i);
1714 }
1715 }
1716 */
1717
1718 void reset_scr(int32_t scr)
1719 {
1720 /*
1721 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1722 for(unsigned i=0; i<sizeof(mapscr); i++)
1723 *(di++) = 0;
1724 TheMaps[scr].valid=mVERSION;
1725 */
1726
1727 TheMaps[scr].zero_memory();
1728 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1729
1730 for(int32_t i=0; i<6; i++)
1731 {
1732 //these will be uncommented later
1733 //TheMaps[scr].layerxsize[i]=16;
1734 //TheMaps[scr].layerysize[i]=11;
1735 TheMaps[scr].layeropacity[i]=255;
1736 }
1737
1738 TheMaps[scr].valid=mVERSION;
1739
1740 }
1741
1742 /* For reference:
1743
1744 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1745 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1746 */
1747
1748 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1749 {
1750
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1751 {
1752
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1753 {
1754
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1755 {
1756
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1757 {
1758 1968 return false;
1759 }
1760
1761
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1762 {
1763 return false;
1764 }
1765
1766
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1767 {
1768 return false;
1769 }
1770
1771
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1772 {
1773 return false;
1774 }
1775 58104 }
1776
1777
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1778 {
1779 return false;
1780 }
1781
1782
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1783 {
1784 return false;
1785 }
1786
1787
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1788 {
1789 return false;
1790 }
1791
1792
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1793 {
1794 return false;
1795 }
1796 87156 }
1797
1798
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1799 {
1800
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1801 {
1802 return false;
1803 }
1804
1805
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1806 {
1807 return false;
1808 }
1809
1810
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1811 {
1812 return false;
1813 }
1814
1815
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1816 {
1817 return false;
1818 }
1819
1820
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1821 {
1822 return false;
1823 }
1824 3228 }
1825
1826
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1827 {
1828
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1829 {
1830 return false;
1831 }
1832
1833
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1834 {
1835 return false;
1836 }
1837
1838
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1839 {
1840 return false;
1841 }
1842
1843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1844 {
1845 return false;
1846 }
1847 4842 }
1848
1849
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1850 {
1851 return false;
1852 }
1853
1854
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1855 {
1856 return false;
1857 }
1858 14526 }
1859
1860 1614 return true;
1861 3582 }
1862
1863 int32_t doortranslations_u[9][4]=
1864 {
1865 {37,38,53,54},
1866 {37,38,39,40},
1867 {37,38,55,56},
1868 {37,38,39,40},
1869 {37,38,53,54},
1870 {37,38,53,54},
1871 {37,38,53,54},
1872 {7,8,23,24},
1873 {7,8,41,42}
1874 };
1875
1876 int32_t doortranslations_d[9][4]=
1877 {
1878 {117,118,133,134},
1879 {135,136,133,134},
1880 {119,120,133,134},
1881 {135,136,133,134},
1882 {117,118,133,134},
1883 {117,118,133,134},
1884 {117,118,133,134},
1885 {151,152,167,168},
1886 {137,138,167,168},
1887 };
1888
1889 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1890 int32_t doortranslations_l[9][6]=
1891 {
1892 {66,67,82,83,98,99},
1893 {66,68,82,84,98,100},
1894 {66,69,82,85,98,101},
1895 {66,68,82,84,98,100},
1896 {66,67,82,83,98,99},
1897 {66,67,82,83,98,99},
1898 {66,67,82,83,98,99},
1899 {64,65,80,81,96,97},
1900 {64,65,80,114,96,97},
1901 };
1902
1903 int32_t doortranslations_r[9][6]=
1904 {
1905
1906 {76,77,92,93,108,109},
1907 {75,77,91,93,107,109},
1908 {74,77,90,93,106,109},
1909 {75,77,91,93,107,109},
1910 {76,77,92,93,108,109},
1911 {76,77,92,93,108,109},
1912 {76,77,92,93,108,109},
1913 {78,79,94,95,110,111},
1914 {78,79,125,95,110,111},
1915 };
1916
1917 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1918 {
1919 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1920 }
1921
1922 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1923 {
1924 //these are here to bypass compiler warnings about unused arguments
1925 308180 map=map;
1926 308180 scr=scr;
1927 308180 pos=pos;
1928
1929 //what does this function do?
1930 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1931 308180 return 2;
1932 }
1933
1934 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1935 {
1936
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1937 {
1938 5450 return 0;
1939 }
1940
1941 DoorComboSet tempdcs;
1942 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1943
1944 //up
1945
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1946 {
1947
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1948 {
1949 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1950 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1951 58392 }
1952 14598 }
1953
1954 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1955 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1956 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1957 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1958 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1959 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1960
1961 //down
1962
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1963 {
1964
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1965 {
1966 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1967 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1968 58392 }
1969 14598 }
1970
1971 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1972
1973 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1974 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1975 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1976 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1977 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1978
1979 //left
1980 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1981
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1982 {
1983
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1984 {
1985 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1986 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1987 87588 }
1988 14598 }
1989
1990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1991 {
1992 if((j!=2)&&(j!=3))
1993 {
1994 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1995 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1996 }
1997 }
1998
1999 1622 tempdcs.bombdoorcombo_l[0]=0;
2000 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2001 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2002 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2003 1622 tempdcs.bombdoorcombo_l[2]=0;
2004 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2005 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2006 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2007
2008 //right
2009
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2010 {
2011
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2012 {
2013 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2014 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2015 87588 }
2016 14598 }
2017
2018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2019 {
2020 if((j!=2)&&(j!=3))
2021 {
2022 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2023 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2024 }
2025 }
2026
2027 1622 tempdcs.bombdoorcombo_r[0]=0;
2028 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2029 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2030 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2031 1622 tempdcs.bombdoorcombo_r[2]=0;
2032 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2033 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2034 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2035
2036 int32_t k;
2037
2038
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2039 {
2040
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2041 {
2042 1614 break;
2043 }
2044 1968 }
2045
2046
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2047 {
2048 8 DoorComboSets[k]=tempdcs;
2049 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2050 8 ++door_combo_set_count;
2051 8 }
2052
2053 1622 return k;
2054 /*
2055 doorcombo_u[9][4];
2056 doorcset_u[9][4];
2057 doorcombo_d[9][4];
2058 doorcset_d[9][4];
2059 doorcombo_l[9][6];
2060 doorcset_l[9][6];
2061 doorcombo_r[9][6];
2062 doorcset_r[9][6];
2063 bombdoorcombo_u[2];
2064 bombdoorcset_u[2];
2065 bombdoorcombo_d[2];
2066 bombdoorcset_d[2];
2067 bombdoorcombo_l[3];
2068 bombdoorcset_l[3];
2069 bombdoorcombo_r[3];
2070 bombdoorcset_r[3];
2071 walkthroughcombo[4];
2072 walkthroughcset[4];
2073 */
2074 7072 }
2075
2076 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2077 {
2078 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2079 }
2080
2081 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2082 {
2083
2084 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2085 }
2086
2087 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2088 {
2089 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2090 }
2091
2092
2093 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2094 {
2095 char temp_pwd[30];
2096 9 memset(temp_pwd,0,30);
2097
2098
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2099 {
2100 9 memcpy(temp_pwd,encrypted_pwd,30);
2101 9 temp_pwd[29]=0;
2102
2103
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2104 {
2105 270 temp_pwd[i] -= pwdkey;
2106 270 int32_t t=pwdkey>>15;
2107 270 pwdkey = (pwdkey<<1)+t;
2108 270 }
2109 9 }
2110
2111 9 memcpy(pwd,temp_pwd,30);
2112 9 }
2113
2114
2115 86 bool devpwd()
2116 {
2117 #ifdef _DEBUG
2118 return true;
2119 #endif
2120 86 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2121 }
2122 bool check_questpwd(zquestheader *Header, char *pwd)
2123 {
2124 #if DEVLEVEL > 3
2125 return true;
2126 #endif
2127
2128 if (devpwd()) return true;
2129 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2130 cvs_MD5Context ctx;
2131 uint8_t md5sum[16];
2132
2133 cvs_MD5Init(&ctx);
2134 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2135 cvs_MD5Final(md5sum, &ctx);
2136
2137 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2138 }
2139
2140 101 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2141 {
2142 101 zprint2("\n");
2143 101 zprint2("[ZQUEST CREATOR METADATA]\n");
2144
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(qst_num < moduledata.max_quest_files)
2145 zprint2("Loading module quest %d\n", qst_num+1);
2146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(path) zprint2("Loading '%s'\n", path);
2147
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
101 if ( tempheader.new_version_id_main > 0 )
2148 {
2149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(tempheader.new_version_id_fourth > 0)
2150 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2151 tempheader.new_version_id_main,tempheader.new_version_id_second,
2152 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2153 97 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2154 97 tempheader.new_version_id_main,tempheader.new_version_id_second,
2155 97 tempheader.new_version_id_third);
2156 97 }
2157 else
2158 {
2159
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2160 {
2161 case 0x255:
2162 {
2163 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2164 break;
2165 }
2166 case 0x254:
2167 {
2168 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2169 break;
2170 }
2171 case 0x250:
2172 {
2173 switch(tempheader.build)
2174 {
2175 case 19:
2176 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2177 case 20:
2178 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2179 case 21:
2180 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2181 case 22:
2182 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2183 case 23:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2185 case 24:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2187 case 25:
2188 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2189 case 26:
2190 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2191 case 27:
2192 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2193 case 28:
2194 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2195 case 29:
2196 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2197 case 30:
2198 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2199 case 31:
2200 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2201 case 32:
2202 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2203 case 33:
2204 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2205 default:
2206 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2207
2208 }
2209 break;
2210 }
2211
2212 case 0x211:
2213 {
2214 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2215 }
2216 case 0x210:
2217 {
2218 zprint2("Last saved in ZQuest Version: 2.10.x");
2219 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2220 break;
2221 }
2222 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2223 case 0x193:
2224 {
2225 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2226 }
2227 case 0x192:
2228 {
2229 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2230 }
2231 case 0x190:
2232 {
2233 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2234 }
2235 case 0x184:
2236 {
2237 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2238 }
2239 case 0x183:
2240 {
2241 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2242 }
2243 case 0x180:
2244 {
2245 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2246 }
2247 default:
2248 {
2249 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2250 }
2251 */
2252 }
2253 }
2254
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
101 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2255 16 zprint2("%s\n", tempheader.getAlphaVerStr());
2256 85 else zprint2("\n");
2257
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2258
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2259
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2261
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 97 times.
101 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2262
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2263 101 zprint2("\n");
2264 101 }
2265
2266 108 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2267 {
2268 int32_t dummy;
2269 zquestheader tempheader;
2270 char dummybuf[80];
2271 byte temp_map_count;
2272 byte temp_midi_flags[MIDIFLAGS_SIZE];
2273 word version;
2274 char temp_pwd[30], temp_pwd2[30];
2275 int16_t temp_pwdkey;
2276 cvs_MD5Context ctx;
2277 108 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2278 108 memset(&tempheader, 0, sizeof(tempheader));
2279 108 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2280
2281
2282
2283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2284 {
2285 Z_message("Unable to read header string\n");
2286 return qe_invalid;
2287 }
2288
2289 // check header
2290
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2291 {
2292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2293 {
2294 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2295 return qe_invalid;
2296 }
2297 4 }
2298
2299 108 int32_t templatepath_len=0;
2300
2301 108 tempheader.external_zinfo = false;
2302 108 read_zinfo = false;
2303
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2304 {
2305 byte padding;
2306
2307
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2308 {
2309 return qe_invalid;
2310 }
2311
2312
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2313 {
2314 return qe_invalid;
2315 }
2316
2317 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2318
2319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2320 {
2321 return qe_version;
2322 }
2323
2324 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2325
2326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2327 {
2328 return qe_invalid;
2329 }
2330
2331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2332 {
2333 return qe_obsolete;
2334 }
2335
2336
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2342 {
2343 return qe_invalid;
2344 }
2345
2346 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2347
2348
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2349 {
2350 return qe_invalid;
2351 }
2352
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2354 {
2355 return qe_invalid;
2356 }
2357
2358 4 FFCore.quest_format[qMapCount] = temp_map_count;
2359
2360
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2361 {
2362 return qe_invalid;
2363 }
2364
2365
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2366 {
2367 return qe_invalid;
2368 }
2369
2370
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2371 {
2372 return qe_invalid;
2373 }
2374
2375
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2376 {
2377 return qe_invalid;
2378 }
2379
2380
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2381 {
2382 return qe_invalid;
2383 }
2384
2385
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2386 {
2387 return qe_invalid;
2388 }
2389
2390
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2391 {
2392 return qe_invalid;
2393 }
2394
2395
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2396 {
2397 return qe_invalid;
2398 }
2399
2400
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2401 {
2402 return qe_invalid;
2403 }
2404 // These fields are expected to end in null bytes!
2405 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2406
2407
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2408 {
2409 return qe_invalid;
2410 }
2411 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2412
2413
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2414 {
2415 return qe_invalid;
2416 }
2417
2418
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2424 {
2425 return qe_invalid;
2426 }
2427
2428 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2429 4 cvs_MD5Init(&ctx);
2430 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2431 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2432
2433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2434 {
2435 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2436 // Not anymore...
2437 memset(tempheader.minver,0,17);
2438 tempheader.build=0;
2439 tempheader.use_keyfile=0;
2440 memset(tempheader.old_foo, 0, 9);
2441 }
2442 else
2443 {
2444
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2445 {
2446 return qe_invalid;
2447 }
2448
2449
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2450 {
2451 return qe_invalid;
2452 }
2453
2454 4 FFCore.quest_format[vBuild] = tempheader.build;
2455
2456
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465 } // starting at minver
2466
2467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2468 {
2469 memset(&quest_rules[4],0,16); // word rules3..rules10
2470 }
2471 else
2472 {
2473
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2474 {
2475 return qe_invalid; // starting at rules3
2476 }
2477
2478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2479 {
2480 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2481 4 }
2482 }
2483
2484
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2485 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2486 {
2487 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2488 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2489 4 }
2490
2491
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2492 {
2493 byte *mf=temp_midi_flags;
2494
2495 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2496 {
2497 mf=(byte*)dummybuf;
2498 }
2499
2500 if(!pfread(mf,32,f,true)) // read new header additions
2501 {
2502 return qe_invalid; // starting at foo2
2503 }
2504
2505 if(!pfread(dummybuf,18,f,true)) // read new header additions
2506 {
2507 return qe_invalid; // starting at foo2
2508 }
2509 }
2510
2511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2512 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2513 {
2514 4 memset(tempheader.templatepath,0,2048);
2515 4 }
2516 else
2517 {
2518 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2519 {
2520 return qe_invalid;
2521 }
2522 }
2523
2524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2525 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2526 {
2527 4 tempheader.use_keyfile=0;
2528 4 }
2529 4 }
2530 else
2531 {
2532 //section id
2533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_mgetl(&dummy,f,true))
2534 {
2535 return qe_invalid;
2536 }
2537
2538 //section version info
2539
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&version,f,true))
2540 {
2541 return qe_invalid;
2542 }
2543
2544 104 FFCore.quest_format[vHeader] = version;
2545
2546
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
2547 {
2548 return qe_invalid;
2549 }
2550
2551 //section size
2552
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
2553 {
2554 return qe_invalid;
2555 }
2556
2557 //finally... section data
2558
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&tempheader.zelda_version,f,true))
2559 {
2560 return qe_invalid;
2561 }
2562
2563 104 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2564
2565 //do some quick checking...
2566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(tempheader.zelda_version > ZELDA_VERSION)
2567 {
2568 return qe_version;
2569 }
2570
2571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2572 {
2573 return qe_invalid;
2574 }
2575
2576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(bad_version(tempheader.zelda_version))
2577 {
2578 return qe_obsolete;
2579 }
2580
2581
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.build,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
2586 104 FFCore.quest_format[vBuild] = tempheader.build;
2587
2588
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(version<3)
2589 {
2590
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2591 {
2592 return qe_invalid;
2593 }
2594
2595
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2596 {
2597 return qe_invalid;
2598 }
2599
2600 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2601 5 cvs_MD5Init(&ctx);
2602 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2603 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2604 5 }
2605 else
2606 {
2607
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2608 {
2609 return qe_invalid;
2610 }
2611 }
2612
2613
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&tempheader.internal,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.quest_number,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
2623 104 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2624
2625 104 size_t versz = version < 8 ? 9 : 16;
2626
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.version,versz,f,true))
2627 {
2628 return qe_invalid;
2629 }
2630
2631 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2632 //needs to be copied as char[9] or stored as a s.str
2633
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.minver,versz,f,true))
2634 {
2635 return qe_invalid;
2636 }
2637
2638 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2639
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2640 {
2641 return qe_invalid;
2642 }
2643 104 tempheader.title[sizeof(tempheader.title)-1] = 0;
2644
2645
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2646 {
2647 return qe_invalid;
2648 }
2649 104 tempheader.author[sizeof(tempheader.author)-1] = 0;
2650
2651
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.use_keyfile,f,true))
2652 {
2653 return qe_invalid;
2654 }
2655
2656 /*
2657 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2658 {
2659 return qe_invalid;
2660 }
2661 */
2662
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2663 {
2664 return qe_invalid;
2665 }
2666
2667
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(&dummybuf,4,f,true))
2668 {
2669 return qe_invalid;
2670 }
2671
2672
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2673 {
2674 return qe_invalid;
2675 }
2676
2677
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(dummybuf,14,f,true))
2678 {
2679 return qe_invalid;
2680 }
2681
2682 104 templatepath_len=sizeof(tempheader.templatepath);
2683
2684
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(version==1)
2685 {
2686 5 templatepath_len=280;
2687 5 }
2688
2689
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2690 {
2691 return qe_invalid;
2692 }
2693
2694
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_map_count,f,true))
2695 {
2696 return qe_invalid;
2697 }
2698
2699
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(version>=4)
2700 {
2701
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2702 {
2703 return qe_invalid;
2704 }
2705
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2706 {
2707 return qe_invalid;
2708 }
2709
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2710 {
2711 return qe_invalid;
2712 }
2713
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2714 {
2715 return qe_invalid;
2716 }
2717
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2718 {
2719 return qe_invalid;
2720 }
2721
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2722 {
2723 return qe_invalid;
2724 }
2725
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2726 {
2727 return qe_invalid;
2728 }
2729
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2730 {
2731 return qe_invalid;
2732 }
2733
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2734 {
2735 return qe_invalid;
2736 }
2737
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2738 {
2739 return qe_invalid;
2740 }
2741
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2742 {
2743 return qe_invalid;
2744 }
2745
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2746 {
2747 return qe_invalid;
2748 }
2749
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2750 {
2751 return qe_invalid;
2752 }
2753
2754
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.new_version_devsig,256,f,true))
2755 {
2756 return qe_invalid;
2757 }
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2759 strcpy(tempheader.new_version_devsig, "EmilyV99");
2760
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.new_version_compilername,256,f,true))
2761 {
2762 return qe_invalid;
2763 }
2764
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2765 {
2766 return qe_invalid;
2767 }
2768
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.product_name,1024,f,true))
2769 {
2770 return qe_invalid;
2771 }
2772
2773
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&tempheader.compilerid,f,true))
2774 {
2775 return qe_invalid;
2776 }
2777
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2778 {
2779 return qe_invalid;
2780 }
2781
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2782 {
2783 return qe_invalid;
2784 }
2785
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2786 {
2787 return qe_invalid;
2788 }
2789
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2790 {
2791 return qe_invalid;
2792 }
2793
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&tempheader.developerid,f,true))
2794 {
2795 return qe_invalid;
2796 }
2797
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2798 {
2799 return qe_invalid;
2800 }
2801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.build_datestamp,256,f,true))
2802 {
2803 return qe_invalid;
2804 }
2805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!pfread(tempheader.build_timestamp,256,f,true))
2806 {
2807 return qe_invalid;
2808 }
2809 23 }
2810 else // <4
2811 {
2812 81 tempheader.new_version_id_main = 0;
2813 81 tempheader.new_version_id_second = 0;
2814 81 tempheader.new_version_id_third = 0;
2815 81 tempheader.new_version_id_fourth = 0;
2816 81 tempheader.new_version_id_alpha = 0;
2817 81 tempheader.new_version_id_beta = 0;
2818 81 tempheader.new_version_id_gamma = 0;
2819 81 tempheader.new_version_id_release = 0;
2820 81 tempheader.new_version_id_date_year = 0;
2821 81 tempheader.new_version_id_date_month = 0;
2822 81 tempheader.new_version_id_date_day = 0;
2823 81 tempheader.new_version_id_date_hour = 0;
2824 81 tempheader.new_version_id_date_minute = 0;
2825
2826 81 memset(tempheader.new_version_devsig, 0, 256);
2827 81 memset(tempheader.new_version_compilername, 0, 256);
2828 81 memset(tempheader.new_version_compilerversion, 0, 256);
2829 81 memset(tempheader.product_name, 0, 1024);
2830 81 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2831
2832 81 tempheader.compilerid = 0;
2833 81 tempheader.compilerversionnumber_first = 0;
2834 81 tempheader.compilerversionnumber_second = 0;
2835 81 tempheader.compilerversionnumber_third = 0;
2836 81 tempheader.compilerversionnumber_fourth = 0;
2837 81 tempheader.developerid = 0;
2838
2839 81 memset(tempheader.made_in_module_name, 0, 1024);
2840 81 memset(tempheader.build_datestamp, 0, 256);
2841 81 memset(tempheader.build_timestamp, 0, 256);
2842 }
2843
2844
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( version >= 5 )
2845 {
2846
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!pfread(tempheader.build_timezone,6,f,true))
2847 {
2848 return qe_invalid;
2849 }
2850 23 }
2851 else // < 5
2852 {
2853 81 memset(tempheader.build_timezone, 0, 6);
2854 }
2855
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if ( version >= 6 )
2856 {
2857 byte b;
2858
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&b,f,true))
2859 {
2860 return qe_invalid;
2861 }
2862 23 tempheader.external_zinfo = b?true:false;
2863 23 read_zinfo = true;
2864 23 }
2865
2866
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(version >= 7)
2867 {
2868
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2869 {
2870 return qe_invalid;
2871 }
2872 23 }
2873 else
2874 {
2875 81 tempheader.new_version_is_nightly = false;
2876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(tempheader.zelda_version < 0x255)
2877 {
2878
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
81 switch(tempheader.zelda_version)
2879 {
2880 case 0x254:
2881 tempheader.new_version_id_main = 2;
2882 tempheader.new_version_id_second = 54;
2883 break;
2884 case 0x250:
2885
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 1 times.
76 switch(tempheader.build)
2886 {
2887 case 19:
2888 tempheader.new_version_id_main = 2;
2889 tempheader.new_version_id_second = 50;
2890 tempheader.new_version_id_gamma = 1;
2891 break;
2892 case 20:
2893 tempheader.new_version_id_main = 2;
2894 tempheader.new_version_id_second = 50;
2895 tempheader.new_version_id_gamma = 2;
2896 break;
2897 case 21:
2898 tempheader.new_version_id_main = 2;
2899 tempheader.new_version_id_second = 50;
2900 tempheader.new_version_id_gamma = 3;
2901 break;
2902 case 22:
2903 tempheader.new_version_id_main = 2;
2904 tempheader.new_version_id_second = 50;
2905 tempheader.new_version_id_gamma = 4;
2906 break;
2907 case 23:
2908 tempheader.new_version_id_main = 2;
2909 tempheader.new_version_id_second = 50;
2910 tempheader.new_version_id_gamma = 5;
2911 break;
2912 case 24:
2913 22 tempheader.new_version_id_main = 2;
2914 22 tempheader.new_version_id_second = 50;
2915 22 tempheader.new_version_id_release = -1;
2916 22 break;
2917 case 25:
2918 tempheader.new_version_id_main = 2;
2919 tempheader.new_version_id_second = 50;
2920 tempheader.new_version_id_third = 1;
2921 tempheader.new_version_id_gamma = 1;
2922 break;
2923 case 26:
2924 tempheader.new_version_id_main = 2;
2925 tempheader.new_version_id_second = 50;
2926 tempheader.new_version_id_third = 1;
2927 tempheader.new_version_id_gamma = 2;
2928 break;
2929 case 27:
2930 tempheader.new_version_id_main = 2;
2931 tempheader.new_version_id_second = 50;
2932 tempheader.new_version_id_third = 1;
2933 tempheader.new_version_id_gamma = 3;
2934 break;
2935 case 28:
2936 5 tempheader.new_version_id_main = 2;
2937 5 tempheader.new_version_id_second = 50;
2938 5 tempheader.new_version_id_third = 1;
2939 5 tempheader.new_version_id_release = -1;
2940 5 break;
2941 case 29:
2942 24 tempheader.new_version_id_main = 2;
2943 24 tempheader.new_version_id_second = 50;
2944 24 tempheader.new_version_id_third = 2;
2945 24 tempheader.new_version_id_release = -1;
2946 24 break;
2947 case 30:
2948 tempheader.new_version_id_main = 2;
2949 tempheader.new_version_id_second = 50;
2950 tempheader.new_version_id_third = 3;
2951 tempheader.new_version_id_gamma = 1;
2952 break;
2953 case 31:
2954 15 tempheader.new_version_id_main = 2;
2955 15 tempheader.new_version_id_second = 53;
2956 15 tempheader.new_version_id_gamma = -1;
2957 15 break;
2958 case 32:
2959 9 tempheader.new_version_id_main = 2;
2960 9 tempheader.new_version_id_second = 53;
2961 9 tempheader.new_version_id_release = -1;
2962 9 break;
2963 case 33:
2964 1 tempheader.new_version_id_main = 2;
2965 1 tempheader.new_version_id_second = 53;
2966 1 tempheader.new_version_id_third = 1;
2967 1 break;
2968 }
2969 76 break;
2970
2971 case 0x211:
2972 tempheader.new_version_id_main = 2;
2973 tempheader.new_version_id_second = 11;
2974 tempheader.new_version_id_beta = tempheader.build;
2975 break;
2976 case 0x210:
2977 5 tempheader.new_version_id_main = 2;
2978 5 tempheader.new_version_id_second = 10;
2979 5 tempheader.new_version_id_beta = tempheader.build;
2980 5 break;
2981 }
2982 81 }
2983 }
2984
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(printmetadata || __isZQuest)
2985 {
2986 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2987 }
2988 }
2989
2990 //{ Version Warning
2991 108 int32_t vercmp = tempheader.compareVer();
2992 108 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2993 108 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2994
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
131 if(vercmp > 0 || (!vercmp &&
2995
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 (astatecmp > 0 || (!astatecmp &&
2996 23 avercmp > 0))))
2997 {
2998 bool r = true;
2999 if(loadquest_report)
3000 {
3001 enter_sys_pal();
3002 AlertDialog("Quest saved in newer version",
3003 "This quest was last saved in a newer version of ZQuest."
3004 " Attempting to load this quest may not work correctly; to"
3005 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3006 "\n\nWould you like to continue loading anyway? (Not recommended)",
3007 [&](bool ret,bool)
3008 {
3009 r = ret;
3010 }).show();
3011 exit_sys_pal();
3012 }
3013 if(!r)
3014 return qe_silenterr;
3015 }
3016
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 else if(tempheader.compareDate() > 0)
3017 {
3018 bool r = true;
3019 if(loadquest_report)
3020 {
3021 enter_sys_pal();
3022 AlertDialog("Quest saved in newer build",
3023 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3024 " issues loading in this build."
3025 "\n{}"
3026 "\n\nWould you like to continue loading anyway?",
3027 tempheader.getVerCmpStr()),
3028 [&](bool ret,bool)
3029 {
3030 r = ret;
3031 }).show();
3032 exit_sys_pal();
3033 }
3034 if(!r)
3035 return qe_silenterr;
3036 }
3037 //}
3038
3039 108 read_ext_zinfo = tempheader.external_zinfo;
3040
3041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
3042 {
3043 108 memcpy(Header, &tempheader, sizeof(tempheader));
3044 108 map_count=temp_map_count;
3045 108 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3046 108 }
3047
3048 108 return 0;
3049 108 }
3050
3051 110 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3052 {
3053 int32_t dummy;
3054 zquestheader tempheader;
3055 110 word s_version=0;
3056 110 dword compatrule_version=0;
3057
3058 110 memcpy(&tempheader, Header, sizeof(tempheader));
3059
3060
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 104 times.
110 if(tempheader.zelda_version >= 0x193)
3061 {
3062 //section version info
3063
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
3064 {
3065 return qe_invalid;
3066 }
3067
3068 104 FFCore.quest_format[vRules] = s_version;
3069
3070
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
3071 {
3072 return qe_invalid;
3073 }
3074
3075
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(s_version > 16)
3076 {
3077
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&compatrule_version,f,true))
3078 {
3079 return qe_invalid;
3080 }
3081 23 }
3082 104 FFCore.quest_format[vCompatRule] = compatrule_version;
3083
3084 //section size
3085
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
3086 {
3087 return qe_invalid;
3088 }
3089
3090
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if ( s_version < 15 )
3091 {
3092 //finally... section data
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3094 {
3095 return qe_invalid;
3096 }
3097 81 }
3098 else
3099 {
3100
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3102 {
3103 return qe_invalid;
3104 }
3105
3106 }
3107 104 }
3108
3109 //al_trace("Rules version %d\n", s_version);
3110 //{ bunch of compat stuff
3111 110 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3112
3113
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(s_version<2)
3114 {
3115 9 set_bit(quest_rules,14,0);
3116 9 set_bit(quest_rules,27,0);
3117 9 set_bit(quest_rules,28,0);
3118 9 set_bit(quest_rules,29,0);
3119 9 set_bit(quest_rules,30,0);
3120 9 set_bit(quest_rules,32,0);
3121 9 set_bit(quest_rules,36,0);
3122 9 set_bit(quest_rules,49,0);
3123 9 set_bit(quest_rules,50,0);
3124 9 set_bit(quest_rules,51,0);
3125 9 set_bit(quest_rules,68,0);
3126 9 set_bit(quest_rules,75,0);
3127 9 set_bit(quest_rules,76,0);
3128 9 set_bit(quest_rules,98,0);
3129 9 set_bit(quest_rules,110,0);
3130 9 set_bit(quest_rules,113,0);
3131 9 set_bit(quest_rules,116,0);
3132 9 set_bit(quest_rules,102,0);
3133 9 set_bit(quest_rules,132,0);
3134 9 }
3135
3136 //Now, do any updates...
3137
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3138 {
3139 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3140 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3141 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3142 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3143 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3144 13 }
3145
3146
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3147 {
3148 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3149 8 }
3150
3151
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3152 {
3153 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3154 8 }
3155
3156
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3157 {
3158 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3159 8 }
3160
3161
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version <= 0x210)
3162 {
3163 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3164 9 }
3165
3166
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(tempheader.zelda_version == 0x210)
3167 {
3168 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3169 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3170 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3171 5 }
3172
3173
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version <= 0x210)
3174 {
3175 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3176 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3177 9 }
3178
3179 //might not be correct
3180
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4 times.
110 if(tempheader.zelda_version < 0x210)
3181 {
3182 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3183 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3184 4 }
3185
3186
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version < 0x211)
3187 {
3188 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3189 9 }
3190
3191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3192 {
3193 set_bit(quest_rules, qr_192b163_WARP,1);
3194 }
3195
3196
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(tempheader.zelda_version == 0x210)
3197 {
3198 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3199 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3200 5 }
3201
3202
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3203 {
3204 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3205 13 }
3206
3207
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3208 {
3209 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3210 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3211 13 }
3212
3213
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3214 {
3215 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3216 9 }
3217
3218
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 22 times.
110 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3219 {
3220 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3221 22 }
3222
3223
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3224 {
3225 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3226 13 }
3227
3228
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3229 {
3230 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3231 13 }
3232
3233
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3234 {
3235 35 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3236 35 }
3237
3238
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3239 {
3240 35 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3241 35 }
3242
3243 //Bombchu fix.
3244
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 76 times.
110 if(tempheader.zelda_version == 0x250)
3245 {
3246
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 22 times.
76 if ( tempheader.build == 24 ) //2.50.0
3247 {
3248 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3249 22 }
3250
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 5 times.
76 if ( tempheader.build == 28 ) //2.50.1
3251 {
3252 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3253 5 }
3254
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
76 if ( tempheader.build == 29 ) //2.50.2
3255 {
3256 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3257 24 }
3258
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( tempheader.build == 30 ) //2.50.3RC1
3259 {
3260 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3261 }
3262 76 }
3263
3264
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 51 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3265 {
3266 // qr_OFFSETEWPNCOLLISIONFIX
3267 // All 'official' quests need this disabled.
3268 // All 2.10 and lower quests need this enabled to preseve compatability.
3269 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3270
3271 //~Gleeok
3272 36 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3273
3274 // Broke in build 695
3275
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
36 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3276 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3277 36 }
3278
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4 times.
110 if (tempheader.zelda_version <= 0x190)
3279 {
3280 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3281 4 }
3282
9/10
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 23 times.
110 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3283 {
3284 86 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3285 86 }
3286
3287
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3288 {
3289 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3290 9 }
3291
3292
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3293 {
3294 85 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3295 85 }
3296
3297
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( tempheader.zelda_version < 0x250 )
3298 {
3299 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3300 9 }
3301
3302
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 3)
3303 {
3304 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3305 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3306 9 }
3307
3308
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<4)
3309 {
3310 9 set_bit(quest_rules,10,0);
3311 9 }
3312
3313
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<5)
3314 {
3315 9 set_bit(quest_rules,27,0);
3316 9 }
3317
3318
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<6)
3319 {
3320 9 set_bit(quest_rules,46,0);
3321 9 }
3322
3323
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<7) // January 2008
3324 {
3325 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3326 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3327 9 }
3328
3329
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version<8)
3330 {
3331 9 set_bit(quest_rules, 12, 0);
3332 9 }
3333 else
3334 {
3335 99 set_bit(deprecated_rules, 12, 0);
3336 }
3337
3338
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<9) // October 2008
3339 {
3340 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3341 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3342 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3343 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3344 9 }
3345
3346
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<10) // December 2008
3347 {
3348 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3349 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3350 9 }
3351
3352
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<11) // April 2009
3353 {
3354 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3355 9 }
3356
3357
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<12) // December 2009
3358 {
3359 9 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3360 9 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3361 9 }
3362
3363 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3364
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 13)
3365 {
3366 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3367 9 }
3368
3369 // Not entirely sure this is the best place for this...
3370 //2.50.2 bitmap offset fix
3371 108 memset(extra_rules, 0, EXTRARULES_SIZE);
3372
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 49 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3373 {
3374 36 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3375 36 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3376 36 }
3377 //required because quest templates also used this bit, although
3378 //it never did anything, before. -Z
3379
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 76 times.
108 if ( tempheader.zelda_version == 0x250 )
3380 {
3381
5/6
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 37 times.
76 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3382 {
3383 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3384 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3385 39 }
3386 76 }
3387
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if ( tempheader.zelda_version == 0x254 )
3388 {
3389 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3390 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3391 }
3392
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
108 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3393 {
3394 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3395 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3396 }
3397 //optimise fast drawing for older versions.
3398
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3399 {
3400 85 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3401 85 }
3402 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3403 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3404 //older quests can set the rule by hand. We need a new qst.dat again.
3405
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3406 {
3407 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3408 }
3409
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3410 {
3411 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3412 }
3413
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3414 {
3415 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3416 }
3417
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if ( tempheader.zelda_version < 0x254 )
3418 {
3419 85 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3420 85 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3421 85 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3422 85 }
3423
3424 //item scripts continue to run
3425
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3426 {
3427 85 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3428 85 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3429 85 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3430 85 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3431 85 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3432 85 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3433 85 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3434 85 }
3435
3436
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3437 {
3438 85 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3439 85 }
3440
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3441 {
3442 85 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3443 85 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3444 85 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3445 85 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3446 85 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3447 85 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3448 85 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3449 85 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3450
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 2 times.
85 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3451 {
3452 2 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3453 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3454 //Now they **do**, unless you disable that behaviour.
3455 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3456 //now enable the disable L/R item swap on load.
3457 2 }
3458
3459 85 }
3460
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3461 {
3462 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3463 85 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3464 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3465 //animations ending earlier than they should.
3466 85 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3467 //Enemies would ignore solidity on the top half of combos
3468 85 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3469 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3470 85 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3471 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3472 85 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3473 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3474 85 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3475 85 }
3476
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if ( tempheader.zelda_version < 0x255 )
3477 {
3478 85 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3479 85 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3480 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3481 85 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3482 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3483 85 }
3484
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3485 {
3486 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3487 85 }
3488
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3489 {
3490 85 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3491 85 }
3492
3493
3494
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3495 {
3496 85 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3497 85 }
3498
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3499 {
3500 85 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3501 85 }
3502
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3503 {
3504 85 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3505 85 }
3506
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3507 {
3508 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3509
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3510 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3511 85 }
3512
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3513 {
3514 85 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3515 85 }
3516
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3517 {
3518 85 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3519 85 }
3520
3521
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if ( tempheader.zelda_version < 0x254 )
3522 {
3523 85 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3524 85 }
3525 //Sideview spikes in 2.50.0
3526
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 54 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3527 {
3528 31 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3529 31 }
3530 //more 2.50 fixes -Z
3531
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 25 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3532 {
3533 60 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3534 60 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3535 60 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3536 60 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3537 60 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3538
3539 60 }
3540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3541 {
3542 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3543 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3544 }
3545
3546
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(tempheader.zelda_version < 0x193)
3547 {
3548 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3549 4 }
3550
3551
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(tempheader.zelda_version < 0x255)
3552 {
3553 85 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3554 85 }
3555
3556
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3557 {
3558 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3559 9 }
3560
3561
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3562 {
3563 85 set_bit(quest_rules,qr_OLD_F6,1);
3564 85 }
3565
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3566 {
3567 85 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3568 85 }
3569
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3570 {
3571 85 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3572 85 }
3573
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3574 {
3575 85 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3576 85 }
3577 //}
3578
3579
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3580 85 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3581
3582
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 2) //Old CSet2 Handling
3583 85 set_bit(quest_rules,qr_OLDCS2,1);
3584
3585
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3586 85 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3587
3588
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3589 85 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3590
3591
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 76 times.
108 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3592 76 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3593
3594
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3595 85 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3596
3597
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3598 85 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3599
3600
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3601 85 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3602
3603
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 9)
3604 {
3605 //Hardcoded BS Patras
3606 85 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3607 //Hardcoded Patra Inner Eye offsets
3608 85 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3609 //Broken 'Big enemy' animation style
3610 85 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3611 //Broken Attribute 31/32
3612 85 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3613 85 }
3614
3615
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 10) //Shared candle use limits
3616 85 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3617
3618
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 11) //No cross-screen return points
3619 85 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3620
3621
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 12)
3622 {
3623 //Old fire trail duration
3624 85 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3625 //Old Intro String in Ganon Room Behavior
3626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3627 85 else set_bit(quest_rules,qr_GANONINTRO,1);
3628 85 }
3629
3630
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
108 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3631 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3632
3633
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 14) //Old Bridge Combo Behavior
3634 85 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3635
3636
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 15) //Broken Z3 Animation
3637 85 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3638
3639
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3640 85 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3641
3642
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 17)
3643 {
3644 //Old Quake/DrawYOffset behavior
3645 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3646 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3647 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3648 85 }
3649
3650
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 18)
3651 {
3652 //Broken DrawScreen Derivative Functions
3653 85 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3654 //Scrolling Cancels Charge
3655 85 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3656 85 }
3657
3658
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3659 85 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3660
3661
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 20)
3662 85 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3663
3664
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 21)
3665 {
3666 85 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3667 85 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3668 85 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3669 85 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3670 85 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3671 85 }
3672
3673
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 22)
3674 85 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3675
3676
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 23)
3677 85 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3678
3679
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 24)
3680 {
3681 85 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3682 85 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3683 85 }
3684
3685
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 25)
3686 {
3687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3688 85 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3689 85 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3690 85 }
3691
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 26)
3692 {
3693 85 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3694 85 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3695 85 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3696 85 }
3697
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3698 {
3699
2/2
✓ Branch 0 taken 25585 times.
✓ Branch 1 taken 85 times.
25670 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3700 25585 set_bit(quest_rules,q,0);
3701
2/2
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 85 times.
9605 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3702 9520 set_bit(quest_rules,q,0);
3703 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3704 85 }
3705
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 28)
3706 87 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3707
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 29)
3708 87 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3709
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 30)
3710 {
3711 87 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3712 87 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3713 87 }
3714
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 31)
3715 {
3716 87 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3717 87 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3718 87 }
3719
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 32)
3720 87 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3721
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(compatrule_version < 33)
3722 87 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3723
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 89 times.
108 if(compatrule_version < 34)
3724 {
3725 89 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3726 89 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3727 89 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3728 89 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3729 89 }
3730
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 90 times.
108 if(compatrule_version < 35)
3731 {
3732 // Leaving this commented for now, might need to enable later -Em
3733 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3734 90 }
3735
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 90 times.
108 if(compatrule_version < 36)
3736 90 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3737
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 37)
3738 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3739
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 38)
3740 99 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3741
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 39)
3742 99 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3743
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 40)
3744 99 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3745
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 101 times.
108 if(compatrule_version < 41)
3746 101 set_bit(quest_rules,qr_BROKENHITBY,1);
3747
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 101 times.
108 if(compatrule_version < 42)
3748 101 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3749
3750 108 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3751
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if (s_version < 16)
3752 85 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3753
3754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
3755 108 memcpy(Header, &tempheader, sizeof(tempheader));
3756
3757 108 return 0;
3758 108 }
3759
3760 897866 void init_msgstr(MsgStr *str)
3761 {
3762 897866 str->s = "";
3763 897866 str->s.shrink_to_fit();
3764 897866 str->nextstring=0;
3765 897866 str->tile=0;
3766 897866 str->cset=0;
3767 897866 str->trans=false;
3768 897866 str->font=font_zfont;
3769 897866 str->y=32;
3770 897866 str->sfx=18;
3771 897866 str->listpos=0;
3772 897866 str->x=24;
3773 897866 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3774 897866 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3775 897866 str->hspace=0;
3776 897866 str->vspace=0;
3777 897866 str->stringflags=0;
3778 897866 str->margins[up] = 8;
3779 897866 str->margins[down] = 0;
3780 897866 str->margins[left] = 8;
3781 897866 str->margins[right] = 0;
3782 897866 str->portrait_tile = 0;
3783 897866 str->portrait_cset = 0;
3784 897866 str->portrait_x = 0;
3785 897866 str->portrait_y = 0;
3786 897866 str->portrait_tw = 1;
3787 897866 str->portrait_th = 1;
3788 897866 str->shadow_type = 0;
3789 897866 str->shadow_color = 0;
3790 897866 str->drawlayer = 6;
3791 897866 }
3792
3793 108 void init_msgstrings(int32_t start, int32_t end)
3794 {
3795
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(end <= start || end-start > msg_strings_size)
3796 return;
3797
3798
2/2
✓ Branch 0 taken 884736 times.
✓ Branch 1 taken 108 times.
884844 for(int32_t i=start; i<end; i++)
3799 {
3800 884736 init_msgstr(&MsgStrings[i]);
3801 884736 MsgStrings[i].listpos=i;
3802 884736 }
3803
3804
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(start==0)
3805 {
3806 108 MsgStrings[0].s = "(None)";
3807 108 MsgStrings[0].listpos = 0;
3808 108 }
3809 108 }
3810
3811 108 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3812 {
3813 108 MsgStr tempMsgString;
3814
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 init_msgstr(&tempMsgString);
3815
3816 108 word temp_msg_count=0;
3817 word temp_expansion[16];
3818 108 memset(temp_expansion, 0, 16*sizeof(word));
3819 108 char buf[8193] = {0};
3820
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version < 0x193)
3821 {
3822 byte tempbyte;
3823 4 int32_t strings_to_read=0;
3824
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3826 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3827 {
3828 4 strings_to_read=128;
3829 4 temp_msg_count=Header->old_str_count;
3830
3831 // Some sort of string count corruption seems to be common in old quests
3832
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3833 {
3834 temp_msg_count=128;
3835 }
3836 4 }
3837 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3838 {
3839 strings_to_read=255;
3840 temp_msg_count=Header->old_str_count;
3841 }
3842 else
3843 {
3844 if(!p_igetw(&temp_msg_count,f,true))
3845 {
3846 return qe_invalid;
3847 }
3848
3849 strings_to_read=temp_msg_count;
3850
3851 if(temp_msg_count >= msg_strings_size)
3852 {
3853 Z_message("Reallocating string buffer...\n");
3854
3855 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3856 // return qe_nomem;
3857
3858 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3859 delete[] MsgStrings;
3860 MsgStrings = new MsgStr[MAXMSGS];
3861 msg_strings_size = MAXMSGS;
3862 for(auto q = 0; q < msg_strings_size; ++q)
3863 {
3864 MsgStrings[q].clear();
3865 }
3866 }
3867 }
3868
3869 //reset the message strings
3870
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3871 {
3872
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3873 4 }
3874
3875
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3876 {
3877
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3878
3879
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3880 {
3881 return qe_invalid;
3882 }
3883
3884 512 buf[74] = '\0';
3885
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3886
3887
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3893 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3894 {
3895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3896
3897
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3903 {
3904 return qe_invalid;
3905 }
3906 512 }
3907 else
3908 {
3909 if(!p_igetw(&tempMsgString.nextstring,f,true))
3910 {
3911 return qe_invalid;
3912 }
3913
3914 if(!pfread(temp_expansion,32,f,true))
3915 {
3916 return qe_invalid;
3917 }
3918 }
3919
3920
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3921 {
3922
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3923 512 }
3924 512 }
3925 4 }
3926 else
3927 {
3928 int32_t dummy_int;
3929 word s_version;
3930 word s_cversion;
3931
3932 //section version info
3933
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_version,f,true))
3934 {
3935 return qe_invalid;
3936 }
3937
3938 104 FFCore.quest_format[vStrings] = s_version;
3939
3940
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_cversion,f,true))
3941 {
3942 return qe_invalid;
3943 }
3944
3945 //al_trace("Strings version %d\n", s_version);
3946 //section size
3947
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetl(&dummy_int,f,true))
3948 {
3949 return qe_invalid;
3950 }
3951
3952 //finally... section data
3953
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&temp_msg_count,f,true))
3954 {
3955 return qe_invalid;
3956 }
3957
3958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(temp_msg_count >= msg_strings_size)
3959 {
3960 Z_message("Reallocating string buffer...\n");
3961
3962 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3963 // return qe_nomem;
3964 delete[] MsgStrings;
3965 MsgStrings = new MsgStr[MAXMSGS];
3966 msg_strings_size = MAXMSGS;
3967 for(auto q = 0; q < msg_strings_size; ++q)
3968 {
3969 MsgStrings[q].clear();
3970 }
3971 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3972 }
3973
3974 //reset the message strings
3975
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(keepdata)
3976 {
3977
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(s_version < 7)
3978
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3979
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 init_msgstrings(0,msg_strings_size);
3980 104 }
3981
3982 104 int32_t string_length=(s_version<2)?73:145;
3983
3984
2/2
✓ Branch 0 taken 12510 times.
✓ Branch 1 taken 104 times.
12614 for(int32_t i=0; i<temp_msg_count; i++)
3985 {
3986
1/2
✓ Branch 0 taken 12510 times.
✗ Branch 1 not taken.
12510 init_msgstr(&tempMsgString);
3987
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 11648 times.
12510 if(s_version > 8)
3988 {
3989
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&string_length,f,true))
3990 {
3991 return qe_invalid;
3992 }
3993 862 }
3994
2/2
✓ Branch 0 taken 12372 times.
✓ Branch 1 taken 138 times.
12510 if (string_length > 0)
3995 {
3996
2/4
✓ Branch 0 taken 12372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12372 times.
✗ Branch 3 not taken.
12372 if (!pfread(buf, string_length, f, true))
3997 {
3998 return qe_invalid;
3999 }
4000 12372 }
4001 else
4002 {
4003 138 buf[0] = 0;
4004 }
4005
4006
2/4
✓ Branch 0 taken 12510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12510 times.
✗ Branch 3 not taken.
12510 if(!p_igetw(&tempMsgString.nextstring,f,true))
4007 {
4008 return qe_invalid;
4009 }
4010
4011
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7864 times.
12510 if(s_version<2)
4012 {
4013 4646 buf[72] = '\0';
4014
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
4015 4646 }
4016 else
4017 {
4018 // June 2008: A bug corrupted the last 4 chars of a string.
4019 // Discard these.
4020
1/2
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
7864 if(s_version<3)
4021 {
4022 for(int32_t j=140; j<144; j++)
4023 {
4024 buf[j] = '\0';
4025 }
4026 }
4027
1/2
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
7864 if(string_length > 8192) string_length = 8192;
4028 7864 buf[string_length]='\0'; //Force-terminate
4029
1/2
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
7864 tempMsgString.s = buf;
4030
4031
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 7002 times.
7864 if ( s_version >= 6 )
4032 {
4033
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&tempMsgString.tile,f,true))
4034 {
4035 return qe_invalid;
4036 }
4037 862 }
4038 else
4039 {
4040
2/4
✓ Branch 0 taken 7002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
7002 if(!p_igetw(&tempMsgString.tile,f,true))
4041 {
4042 return qe_invalid;
4043 }
4044 }
4045
4046
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.cset,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050
4051 byte dummy_char;
4052
4053
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4054 {
4055 return qe_invalid;
4056 }
4057
4058 7864 tempMsgString.trans=dummy_char!=0;
4059
4060
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.font,f,true))
4061 {
4062 return qe_invalid;
4063 }
4064
4065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7864 times.
7864 if(s_version < 5)
4066 {
4067 if(!p_getc(&tempMsgString.y,f,true))
4068 {
4069 return qe_invalid;
4070 }
4071 }
4072 else
4073 {
4074
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_igetw(&tempMsgString.x,f,true))
4075 {
4076 return qe_invalid;
4077 }
4078
4079
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_igetw(&tempMsgString.y,f,true))
4080 {
4081 return qe_invalid;
4082 }
4083
4084
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_igetw(&tempMsgString.w,f,true))
4085 {
4086 return qe_invalid;
4087 }
4088
4089
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_igetw(&tempMsgString.h,f,true))
4090 {
4091 return qe_invalid;
4092 }
4093
4094
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.hspace,f,true))
4095 {
4096 return qe_invalid;
4097 }
4098
4099
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.vspace,f,true))
4100 {
4101 return qe_invalid;
4102 }
4103
4104
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.stringflags,f,true))
4105 {
4106 return qe_invalid;
4107 }
4108 }
4109
4110
2/2
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 862 times.
7864 if(s_version >= 7)
4111 {
4112
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 3448 times.
4310 for(int32_t q = 0; q < 4; ++q)
4113 {
4114
2/4
✓ Branch 0 taken 3448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3448 times.
✗ Branch 3 not taken.
3448 if(!p_getc(&tempMsgString.margins[q],f,true))
4115 {
4116 return qe_invalid;
4117 }
4118 3448 }
4119
4120
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4121 {
4122 return qe_invalid;
4123 }
4124
4125
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4126 {
4127 return qe_invalid;
4128 }
4129
4130
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_x,f,true))
4131 {
4132 return qe_invalid;
4133 }
4134
4135
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_y,f,true))
4136 {
4137 return qe_invalid;
4138 }
4139
4140
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4141 {
4142 return qe_invalid;
4143 }
4144
4145
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_th,f,true))
4146 {
4147 return qe_invalid;
4148 }
4149 862 }
4150
4151
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 7002 times.
7864 if(s_version >= 8)
4152 {
4153
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.shadow_type,f,true))
4154 {
4155 return qe_invalid;
4156 }
4157
4158
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.shadow_color,f,true))
4159 {
4160 return qe_invalid;
4161 }
4162 862 }
4163
4164
2/2
✓ Branch 0 taken 745 times.
✓ Branch 1 taken 7119 times.
7864 if(s_version >= 10)
4165 {
4166
2/4
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745 times.
✗ Branch 3 not taken.
745 if(!p_getc(&tempMsgString.drawlayer,f,true))
4167 {
4168 return qe_invalid;
4169 }
4170 745 }
4171
4172
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_getc(&tempMsgString.sfx,f,true))
4173 {
4174 return qe_invalid;
4175 }
4176
4177
1/2
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
7864 if(s_version>3)
4178 {
4179
2/4
✓ Branch 0 taken 7864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7864 times.
✗ Branch 3 not taken.
7864 if(!p_igetw(&tempMsgString.listpos,f,true))
4180 {
4181 return qe_invalid;
4182 }
4183 7864 }
4184 }
4185
4186
1/2
✓ Branch 0 taken 12510 times.
✗ Branch 1 not taken.
12510 if(keepdata==true)
4187 {
4188
1/2
✓ Branch 0 taken 12510 times.
✗ Branch 1 not taken.
12510 MsgStrings[i].copyAll(tempMsgString);
4189 12510 }
4190 12510 }
4191 }
4192
4193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
4194 {
4195 108 msg_count=temp_msg_count;
4196 108 }
4197
4198 108 return 0;
4199 108 }
4200
4201 108 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4202 {
4203
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
4204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4205 {
4206 4 return 0;
4207 }
4208
4209 104 word temp_door_combo_set_count=0;
4210 DoorComboSet tempDoorComboSet;
4211 word dummy_word;
4212 int32_t dummy_long;
4213 byte padding;
4214 104 int32_t s_version = 0;
4215
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4217 {
4218
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4219 {
4220 26624 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4221 26624 }
4222 104 }
4223
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(Header->zelda_version > 0x192)
4225 {
4226 //section version info
4227
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
4228 {
4229 return qe_invalid;
4230 }
4231
4232 104 FFCore.quest_format[vDoors] = s_version;
4233
4234 //al_trace("Door combo sets version %d\n", dummy_word);
4235
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy_word,f,true))
4236 {
4237 return qe_invalid;
4238 }
4239
4240 //section size
4241
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy_long,f,true))
4242 {
4243 return qe_invalid;
4244 }
4245 104 }
4246
4247 //finally... section data
4248
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_door_combo_set_count,f,true))
4249 {
4250 return qe_invalid;
4251 }
4252
4253
2/2
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 104 times.
885 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4254 {
4255 781 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4256
4257 //name
4258
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4259 {
4260 return qe_invalid;
4261 }
4262
4263
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(Header->zelda_version < 0x193)
4264 {
4265 if(!p_getc(&padding,f,true))
4266 {
4267 return qe_invalid;
4268 }
4269 }
4270
4271 //up door
4272
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4273 {
4274
2/2
✓ Branch 0 taken 28116 times.
✓ Branch 1 taken 7029 times.
35145 for(int32_t k=0; k<4; k++)
4275 {
4276
1/2
✓ Branch 0 taken 28116 times.
✗ Branch 1 not taken.
28116 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4277 {
4278 return qe_invalid;
4279 }
4280 28116 }
4281 7029 }
4282
4283
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4284 {
4285
2/2
✓ Branch 0 taken 28116 times.
✓ Branch 1 taken 7029 times.
35145 for(int32_t k=0; k<4; k++)
4286 {
4287
1/2
✓ Branch 0 taken 28116 times.
✗ Branch 1 not taken.
28116 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4288 {
4289 return qe_invalid;
4290 }
4291 28116 }
4292 7029 }
4293
4294 //down door
4295
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4296 {
4297
2/2
✓ Branch 0 taken 28116 times.
✓ Branch 1 taken 7029 times.
35145 for(int32_t k=0; k<4; k++)
4298 {
4299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28116 times.
28116 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4300 {
4301 return qe_invalid;
4302 }
4303 28116 }
4304 7029 }
4305
4306
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4307 {
4308
2/2
✓ Branch 0 taken 28116 times.
✓ Branch 1 taken 7029 times.
35145 for(int32_t k=0; k<4; k++)
4309 {
4310
1/2
✓ Branch 0 taken 28116 times.
✗ Branch 1 not taken.
28116 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4311 {
4312 return qe_invalid;
4313 }
4314 28116 }
4315 7029 }
4316
4317 //left door
4318
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4319 {
4320
2/2
✓ Branch 0 taken 42174 times.
✓ Branch 1 taken 7029 times.
49203 for(int32_t k=0; k<6; k++)
4321 {
4322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42174 times.
42174 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4323 {
4324 return qe_invalid;
4325 }
4326 42174 }
4327 7029 }
4328
4329
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4330 {
4331
2/2
✓ Branch 0 taken 42174 times.
✓ Branch 1 taken 7029 times.
49203 for(int32_t k=0; k<6; k++)
4332 {
4333
1/2
✓ Branch 0 taken 42174 times.
✗ Branch 1 not taken.
42174 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4334 {
4335 return qe_invalid;
4336 }
4337 42174 }
4338 7029 }
4339
4340 //right door
4341
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4342 {
4343
2/2
✓ Branch 0 taken 42174 times.
✓ Branch 1 taken 7029 times.
49203 for(int32_t k=0; k<6; k++)
4344 {
4345
1/2
✓ Branch 0 taken 42174 times.
✗ Branch 1 not taken.
42174 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4346 {
4347 return qe_invalid;
4348 }
4349 42174 }
4350 7029 }
4351
4352
2/2
✓ Branch 0 taken 7029 times.
✓ Branch 1 taken 781 times.
7810 for(int32_t j=0; j<9; j++)
4353 {
4354
2/2
✓ Branch 0 taken 42174 times.
✓ Branch 1 taken 7029 times.
49203 for(int32_t k=0; k<6; k++)
4355 {
4356
1/2
✓ Branch 0 taken 42174 times.
✗ Branch 1 not taken.
42174 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4357 {
4358 return qe_invalid;
4359 }
4360 42174 }
4361 7029 }
4362
4363 //up bomb rubble
4364
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 781 times.
2343 for(int32_t j=0; j<2; j++)
4365 {
4366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4367 {
4368 return qe_invalid;
4369 }
4370 1562 }
4371
4372
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 781 times.
2343 for(int32_t j=0; j<2; j++)
4373 {
4374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4375 {
4376 return qe_invalid;
4377 }
4378 1562 }
4379
4380 //down bomb rubble
4381
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 781 times.
2343 for(int32_t j=0; j<2; j++)
4382 {
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4384 {
4385 return qe_invalid;
4386 }
4387 1562 }
4388
4389
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 781 times.
2343 for(int32_t j=0; j<2; j++)
4390 {
4391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4392 {
4393 return qe_invalid;
4394 }
4395 1562 }
4396
4397 //left bomb rubble
4398
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 781 times.
3124 for(int32_t j=0; j<3; j++)
4399 {
4400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4401 {
4402 return qe_invalid;
4403 }
4404 2343 }
4405
4406
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 781 times.
3124 for(int32_t j=0; j<3; j++)
4407 {
4408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4409 {
4410 return qe_invalid;
4411 }
4412 2343 }
4413
4414
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(Header->zelda_version < 0x193)
4415 {
4416 if(!p_getc(&padding,f,true))
4417 {
4418 return qe_invalid;
4419 }
4420
4421 }
4422
4423 //right bomb rubble
4424
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 781 times.
3124 for(int32_t j=0; j<3; j++)
4425 {
4426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4427 {
4428 return qe_invalid;
4429 }
4430 2343 }
4431
4432
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 781 times.
3124 for(int32_t j=0; j<3; j++)
4433 {
4434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2343 times.
2343 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4435 {
4436 return qe_invalid;
4437 }
4438 2343 }
4439
4440
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(Header->zelda_version < 0x193)
4441 {
4442 if(!p_getc(&padding,f,true))
4443 {
4444 return qe_invalid;
4445 }
4446 }
4447
4448 //walkthrough stuff
4449
2/2
✓ Branch 0 taken 3124 times.
✓ Branch 1 taken 781 times.
3905 for(int32_t j=0; j<4; j++)
4450 {
4451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3124 times.
3124 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4452 {
4453 return qe_invalid;
4454 }
4455 3124 }
4456
4457
2/2
✓ Branch 0 taken 3124 times.
✓ Branch 1 taken 781 times.
3905 for(int32_t j=0; j<4; j++)
4458 {
4459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3124 times.
3124 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4460 {
4461 return qe_invalid;
4462 }
4463 3124 }
4464
4465 //flags
4466
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 781 times.
2343 for(int32_t j=0; j<2; j++)
4467 {
4468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562 times.
1562 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4469 {
4470 return qe_invalid;
4471 }
4472 1562 }
4473
4474
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(Header->zelda_version < 0x193)
4475 {
4476 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4477 {
4478 return qe_invalid;
4479 }
4480 }
4481
4482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
781 if(keepdata==true)
4483 {
4484 781 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4485 781 }
4486 781 }
4487
4488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4489 {
4490 104 door_combo_set_count=temp_door_combo_set_count;
4491 104 }
4492
4493 104 return 0;
4494 108 }
4495
4496 int32_t count_dmaps()
4497 {
4498 int32_t i=MAXDMAPS-1;
4499 bool found=false;
4500
4501 while(i>=0 && !found)
4502 {
4503 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4504 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4505 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4506 found=true;
4507
4508 for(int32_t j=0; j<8; j++)
4509 {
4510 if(DMaps[i].grid[j]!=0)
4511
4512 found=true;
4513 }
4514
4515 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4516 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4517 found=true;
4518
4519 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4520 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4521 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4522 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4523 found=true;
4524
4525 if(!found)
4526 {
4527 i--;
4528 }
4529 }
4530
4531 return i+1;
4532 }
4533
4534
4535 int32_t count_shops(miscQdata *Misc)
4536 {
4537 int32_t i=255,j;
4538 bool found=false;
4539
4540 while(i>=0 && !found)
4541 {
4542 j=2;
4543
4544 while(j>=0 && !found)
4545 {
4546 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4547 {
4548 found=true;
4549 }
4550 else
4551 {
4552 j--;
4553 }
4554 }
4555
4556 if(Misc->shop[i].name[0]!=0)
4557 {
4558 found=true;
4559 }
4560
4561 if(!found)
4562 {
4563 i--;
4564 }
4565 }
4566
4567 return i+1;
4568 }
4569
4570 int32_t count_infos(miscQdata *Misc)
4571 {
4572 int32_t i=255,j;
4573 bool found=false;
4574
4575 while(i>=0 && !found)
4576 {
4577 j=2;
4578
4579 while(j>=0 && !found)
4580 {
4581 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4582 {
4583 found=true;
4584 }
4585 else
4586 {
4587 j--;
4588 }
4589 }
4590
4591 if(Misc->info[i].name[0]!=0)
4592 {
4593 found=true;
4594 }
4595
4596 if(!found)
4597 {
4598 i--;
4599 }
4600 }
4601
4602 return i+1;
4603 }
4604
4605 int32_t count_warprings(miscQdata *Misc)
4606 {
4607 int32_t i=15,j;
4608 bool found=false;
4609
4610 while(i>=0 && !found)
4611 {
4612 j=7;
4613
4614 while(j>=0 && !found)
4615 {
4616 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4617 {
4618 found=true;
4619 }
4620 else
4621 {
4622 j--;
4623 }
4624 }
4625
4626 if(!found)
4627 {
4628 i--;
4629 }
4630 }
4631
4632 return i+1;
4633 }
4634
4635 int32_t count_palcycles(miscQdata *Misc)
4636 {
4637 int32_t i=255,j;
4638 bool found=false;
4639
4640 while(i>=0 && !found)
4641 {
4642 j=2;
4643
4644 while(j>=0 && !found)
4645 {
4646 if(Misc->cycles[i][j].count!=0)
4647 {
4648 found=true;
4649 }
4650 else
4651 {
4652 j--;
4653 }
4654 }
4655
4656 if(!found)
4657 {
4658 i--;
4659 }
4660 }
4661
4662 return i+1;
4663 }
4664
4665 201316 void clear_screen(mapscr *temp_scr)
4666 {
4667 201316 temp_scr->zero_memory();
4668 201316 }
4669
4670 108 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4671 {
4672 108 word dmapstoread=0;
4673 dmap tempDMap;
4674
4675 int32_t dummy;
4676 108 word s_version=0, s_cversion=0;
4677 byte padding;
4678
4679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
4680 {
4681
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<max_dmaps; i++)
4682 {
4683 55296 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4684 55296 sprintf(DMaps[start_dmap+i].title," ");
4685 55296 sprintf(DMaps[start_dmap+i].intro," ");
4686 55296 DMaps[start_dmap+i].type |= dmCAVE;
4687 55296 }
4688 108 }
4689
4690
3/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 4 times.
108 if(!Header || Header->zelda_version > 0x192)
4691 {
4692 //section version info
4693
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
4694 {
4695 return qe_invalid;
4696 }
4697
4698 104 FFCore.quest_format[vDMaps] = s_version;
4699
4700 //al_trace("DMaps version %d\n", s_version);
4701
4702
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
4703 {
4704 return qe_invalid;
4705 }
4706
4707 //section size
4708
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
4709 {
4710 return qe_invalid;
4711 }
4712
4713 //finally... section data
4714
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dmapstoread,f,true))
4715 {
4716 return qe_invalid;
4717 }
4718 104 }
4719 else
4720 {
4721
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4722 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4723 {
4724 4 dmapstoread=32;
4725 4 }
4726 else if(s_version <= 4)
4727 {
4728 dmapstoread=OLDMAXDMAPS;
4729 }
4730 else
4731 {
4732 dmapstoread=MAXDMAPS;
4733 }
4734 }
4735
4736
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 dmapstoread=zc_min(dmapstoread, max_dmaps);
4737
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4738
4739
2/2
✓ Branch 0 taken 52096 times.
✓ Branch 1 taken 108 times.
52204 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4740 {
4741 52096 memset(&tempDMap,0,sizeof(dmap));
4742 52096 sprintf(tempDMap.title," ");
4743 52096 sprintf(tempDMap.intro," ");
4744
4745
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.map,f,keepdata))
4746 {
4747 return qe_invalid;
4748 }
4749
4750
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version <= 4)
4751 {
4752 byte tempbyte;
4753
4754
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4755 {
4756 return qe_invalid;
4757 }
4758
4759 1408 tempDMap.level=(word)tempbyte;
4760 1408 }
4761 else
4762 {
4763
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempDMap.level,f,keepdata))
4764 {
4765 return qe_invalid;
4766 }
4767 }
4768
4769
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.xoff,f,keepdata))
4770 {
4771 return qe_invalid;
4772 }
4773
4774
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.compass,f,keepdata))
4775 {
4776 return qe_invalid;
4777 }
4778
4779
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version > 8) // February 2009
4780 {
4781
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempDMap.color,f,true))
4782 {
4783 return qe_invalid;
4784 }
4785 50688 }
4786 else
4787 {
4788 byte tempbyte;
4789
4790
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4791 {
4792 return qe_invalid;
4793 }
4794
4795 1408 tempDMap.color = (word)tempbyte;
4796 }
4797
4798
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.midi,f,keepdata))
4799 {
4800 return qe_invalid;
4801 }
4802
4803
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.cont,f,keepdata))
4804 {
4805 return qe_invalid;
4806 }
4807
4808
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.type,f,keepdata))
4809 {
4810 return qe_invalid;
4811 }
4812
4813
4/4
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 51409 times.
✓ Branch 2 taken 675 times.
✓ Branch 3 taken 12 times.
52783 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4814
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4815 675 tempDMap.xoff = 0;
4816
4817
2/2
✓ Branch 0 taken 416768 times.
✓ Branch 1 taken 52096 times.
468864 for(int32_t j=0; j<8; j++)
4818 {
4819
1/2
✓ Branch 0 taken 416768 times.
✗ Branch 1 not taken.
416768 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4820 {
4821 return qe_invalid;
4822 }
4823 416768 }
4824
4825
4/8
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51968 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52096 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4826 {
4827
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4828 {
4829 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4830 38 }
4831
4832
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4833 {
4834 4 tempDMap.cont-=tempDMap.xoff;
4835 4 tempDMap.compass-=tempDMap.xoff;
4836 4 }
4837
4838 //forgotten -DD
4839
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4840 {
4841 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4842 90 }
4843 128 }
4844 else
4845 {
4846
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4847 {
4848 return qe_invalid;
4849 }
4850
4851
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4852 {
4853 return qe_invalid;
4854 }
4855
4856
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4857 {
4858 return qe_invalid;
4859 }
4860
4861
3/8
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51968 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
51968 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4862 {
4863 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4864 if(keepdata==true)
4865 {
4866 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4867 }
4868
4869 continue;
4870 }
4871
4872
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4873 {
4874 if(!p_getc(&padding,f,keepdata))
4875 {
4876 return qe_invalid;
4877 }
4878 }
4879
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40192 times.
51968 if ( s_version >= 11 )
4880 {
4881
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4882 {
4883 return qe_invalid;
4884 }
4885 11776 }
4886 else
4887 {
4888
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4889 {
4890 return qe_invalid;
4891 }
4892 }
4893
4894
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4895 {
4896 return qe_invalid;
4897 }
4898
4899
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4900 {
4901 if(!p_getc(&padding,f,keepdata))
4902 {
4903 return qe_invalid;
4904 }
4905 }
4906
4907
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40192 times.
51968 if ( s_version >= 11 )
4908 {
4909
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4910 {
4911 return qe_invalid;
4912 }
4913 11776 }
4914 else
4915 {
4916
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4917 {
4918 return qe_invalid;
4919 }
4920 }
4921
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4922 {
4923 return qe_invalid;
4924 }
4925
4926
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4927 {
4928 if(!p_getc(&padding,f,keepdata))
4929 {
4930 return qe_invalid;
4931 }
4932 }
4933
4934
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40192 times.
51968 if ( s_version >= 11 )
4935 {
4936
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4937 {
4938 return qe_invalid;
4939 }
4940 11776 }
4941 else
4942 {
4943
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4944 {
4945 return qe_invalid;
4946 }
4947 }
4948
4949
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4950 {
4951 return qe_invalid;
4952 }
4953
4954
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4955 {
4956
4957 if(!p_getc(&padding,f,keepdata))
4958 {
4959 return qe_invalid;
4960 }
4961 }
4962
4963
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40192 times.
51968 if ( s_version >= 11 )
4964 {
4965
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4966 {
4967 return qe_invalid;
4968 }
4969 11776 }
4970 else
4971 {
4972
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4973 {
4974 return qe_invalid;
4975 }
4976 }
4977
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4978 {
4979 return qe_invalid;
4980 }
4981
4982
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4983 {
4984 return qe_invalid;
4985 }
4986 }
4987
4988
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version>1)
4989 {
4990
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4991 {
4992 return qe_invalid;
4993 }
4994
4995
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4996 {
4997 return qe_invalid;
4998 }
4999
5000
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
5001 {
5002 return qe_invalid;
5003 }
5004 50688 }
5005
5006
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version>2)
5007 {
5008 byte di[32];
5009
5010
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!pfread(&di, 32, f, true)) return qe_invalid;
5011
5012
2/2
✓ Branch 0 taken 12976128 times.
✓ Branch 1 taken 50688 times.
13026816 for(int32_t j=0; j<MAXITEMS; j++)
5013 {
5014
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 12976121 times.
12976128 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5015 12976121 else tempDMap.disableditems[j]=0;
5016 12976128 }
5017 50688 }
5018
5019
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version >= 6)
5020 {
5021
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempDMap.flags,f,keepdata))
5022 {
5023 return qe_invalid;
5024 }
5025 50688 }
5026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
5027 {
5028 char temp;
5029
5030 if(!p_getc(&temp,f,keepdata))
5031 {
5032 return qe_invalid;
5033 }
5034
5035 tempDMap.flags = temp;
5036 }
5037
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5038 {
5039 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5040 697 }
5041 else
5042 711 tempDMap.flags=0;
5043
5044
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version<7)
5045 {
5046
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5047 697 tempDMap.flags|= dmfVIEWMAP;
5048 1408 }
5049
5050
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version<8)
5051 {
5052
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5053 {
5054 609 tempDMap.type &= ~dmDNGN;
5055 609 tempDMap.type |= dmCAVE;
5056 609 }
5057
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5058 {
5059 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5060 469 }
5061 1408 }
5062
5063
5/8
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 51968 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 51968 times.
✗ Branch 7 not taken.
52096 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5064 51968 && (Header->zelda_version < 0x193))
5065 {
5066 if(!p_getc(&padding,f,keepdata))
5067 {
5068 return qe_invalid;
5069 }
5070 }
5071
5072
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 11776 times.
52096 if(s_version >= 10)
5073 {
5074
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempDMap.sideview,f,keepdata))
5075 {
5076 return qe_invalid;
5077 }
5078 11776 }
5079
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if(s_version < 10) tempDMap.sideview = 0;
5080
5081 //Dmap Scripts
5082
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 11776 times.
52096 if(s_version >= 12)
5083 {
5084
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.script,f,keepdata))
5085 {
5086 return qe_invalid;
5087 }
5088
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
5089 {
5090
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5091 {
5092 return qe_invalid;
5093 }
5094 94208 }
5095 11776 }
5096
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if ( s_version < 12 )
5097 {
5098 40320 tempDMap.script = 0;
5099
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5100 {
5101 322560 tempDMap.initD[q] = 0;
5102 322560 }
5103 40320 }
5104
5105
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 11776 times.
52096 if(s_version >= 13)
5106 {
5107
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
5108 {
5109
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
5110 {
5111
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5112 {
5113 return qe_invalid;
5114 }
5115 6123520 }
5116 94208 }
5117 11776 }
5118
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if ( s_version < 13 )
5119 {
5120 40320 tempDMap.script = 0;
5121
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5122 {
5123
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for ( int32_t w = 0; w < 65; w++ )
5124 20966400 tempDMap.initD_label[q][w] = 0;
5125 322560 }
5126 40320 }
5127
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if(s_version >= 14)
5128 {
5129
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5130 {
5131 return qe_invalid;
5132 }
5133
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5134 {
5135 return qe_invalid;
5136 }
5137
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; ++q )
5138 {
5139
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5140 {
5141 return qe_invalid;
5142 }
5143 94208 }
5144
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for(int32_t q = 0; q < 8; ++q)
5145 {
5146
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; ++w )
5147 {
5148
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5149 {
5150 return qe_invalid;
5151 }
5152 6123520 }
5153 94208 }
5154 11776 }
5155 else
5156 {
5157 40320 tempDMap.active_sub_script = 0;
5158 40320 tempDMap.passive_sub_script = 0;
5159
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5160 {
5161 322560 tempDMap.sub_initD[q] = 0;
5162
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5163 20966400 tempDMap.sub_initD_label[q][w] = 0;
5164 322560 }
5165 }
5166
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if(s_version >= 15)
5167 {
5168
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5169 {
5170 return qe_invalid;
5171 }
5172
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; ++q )
5173 {
5174
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5175 {
5176 return qe_invalid;
5177 }
5178 94208 }
5179
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for(int32_t q = 0; q < 8; ++q)
5180 {
5181
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; ++w )
5182 {
5183
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5184 {
5185 return qe_invalid;
5186 }
5187 6123520 }
5188 94208 }
5189 11776 }
5190 else
5191 {
5192 40320 tempDMap.onmap_script = 0;
5193
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5194 {
5195 322560 tempDMap.onmap_initD[q] = 0;
5196
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5197 {
5198 20966400 tempDMap.onmap_initD_label[q][w] = 0;
5199 20966400 }
5200 322560 }
5201 }
5202
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 40320 times.
52096 if(s_version >= 16)
5203 {
5204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5205 {
5206 return qe_invalid;
5207 }
5208 11776 }
5209 else
5210 {
5211 40320 tempDMap.mirrorDMap = -1;
5212 }
5213
5214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52096 times.
52096 if(keepdata==true)
5215 {
5216 52096 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5217 52096 }
5218 52096 }
5219
5220 108 return 0;
5221 108 }
5222
5223 99 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5224 {
5225 //these are here to bypass compiler warnings about unused arguments
5226 99 Header=Header;
5227
5228 miscQdata temp_misc;
5229 99 word s_version=0, s_cversion=0;
5230 99 int32_t tempsize=0;
5231 word dummyw;
5232
5233 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5234
5235 //section version info
5236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
5237 {
5238 return qe_invalid;
5239 }
5240
5241 99 FFCore.quest_format[vColours] = s_version;
5242
5243 99 al_trace("Misc Colours section version: %d\n", s_version);
5244
5245 //al_trace("Misc. colors version %d\n", s_version);
5246
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5247 {
5248 return qe_invalid;
5249 }
5250
5251
5252 //section size
5253
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5254 {
5255 return qe_invalid;
5256 }
5257
5258 //finally... section data
5259 99 readsize=0;
5260
5261
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.text,f,true))
5262 {
5263 return qe_invalid;
5264 }
5265
5266
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.caption,f,true))
5267 {
5268 return qe_invalid;
5269 }
5270
5271
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5272 {
5273 return qe_invalid;
5274 }
5275
5276
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5277 {
5278 return qe_invalid;
5279 }
5280
5281
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5282 {
5283 return qe_invalid;
5284 }
5285
5286
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5287 {
5288 return qe_invalid;
5289 }
5290
5291
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5292 {
5293 return qe_invalid;
5294 }
5295
5296
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5302 {
5303 return qe_invalid;
5304 }
5305
5306
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5307 {
5308 return qe_invalid;
5309 }
5310
5311
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5312 {
5313 return qe_invalid;
5314 }
5315
5316
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5317 {
5318 return qe_invalid;
5319 }
5320
5321
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5322 {
5323 return qe_invalid;
5324 }
5325
5326
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5327 {
5328 return qe_invalid;
5329 }
5330
5331
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5332 {
5333 return qe_invalid;
5334 }
5335
5336
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5337 {
5338 return qe_invalid;
5339 }
5340
5341
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5347 {
5348 return qe_invalid;
5349 }
5350
5351
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5352 {
5353 return qe_invalid;
5354 }
5355
5356
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5357 {
5358 return qe_invalid;
5359 }
5360
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if(s_version < 4)
5361 {
5362
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5363 return qe_invalid;
5364 76 temp_misc.colors.triforce_tile = dummyw;
5365
5366
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5367 return qe_invalid;
5368 76 temp_misc.colors.triframe_tile = dummyw;
5369
5370
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5371 return qe_invalid;
5372 76 temp_misc.colors.overworld_map_tile = dummyw;
5373
5374
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5375 return qe_invalid;
5376 76 temp_misc.colors.dungeon_map_tile = dummyw;
5377
5378
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5379 return qe_invalid;
5380 76 temp_misc.colors.blueframe_tile = dummyw;
5381
5382
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5383 return qe_invalid;
5384 76 temp_misc.colors.HCpieces_tile = dummyw;
5385 76 }
5386
5387
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5388 {
5389 return qe_invalid;
5390 }
5391
5392
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5393 {
5394 return qe_invalid;
5395 }
5396
5397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version < 2)
5398 {
5399 temp_misc.colors.msgtext = 0x01;
5400 }
5401 else
5402 {
5403
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5404 {
5405 return qe_invalid;
5406 }
5407 }
5408
5409
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if ( s_version >= 3 ) //expanded tile pages to 825
5410 {
5411
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5412 {
5413 return qe_invalid;
5414 }
5415
5416
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5417 {
5418 return qe_invalid;
5419 }
5420
5421
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5422 {
5423 return qe_invalid;
5424 }
5425
5426
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5427 {
5428 return qe_invalid;
5429 }
5430
5431
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5437 {
5438 return qe_invalid;
5439 }
5440 23 }
5441
5442
5443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
5444 {
5445 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5446 99 }
5447
5448 99 return 0;
5449 99 }
5450
5451 99 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5452 {
5453 miscQdata temp_misc;
5454 99 word s_version=0, s_cversion=0;
5455 byte icons;
5456 99 int32_t tempsize=0;
5457
5458 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5459
5460 //section version info
5461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
5462 {
5463 return qe_invalid;
5464 }
5465
5466 99 FFCore.quest_format[vIcons] = s_version;
5467
5468 //al_trace("Game icons version %d\n", s_version);
5469
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5470 {
5471 return qe_invalid;
5472 }
5473
5474
5475 //section size
5476
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5477 {
5478 return qe_invalid;
5479 }
5480
5481 //finally... section data
5482 99 readsize=0;
5483
5484 99 icons=4;
5485
5486
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if ( s_version >= 10 )
5487 {
5488
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<icons; i++)
5489 {
5490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&temp_misc.icons[i],f,true))
5491 {
5492 return qe_invalid;
5493 }
5494 92 }
5495 23 }
5496 else
5497 {
5498
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<icons; i++)
5499 {
5500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_igetw(&temp_misc.icons[i],f,true))
5501 {
5502 return qe_invalid;
5503 }
5504 304 }
5505 }
5506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
5507 {
5508 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5509 99 }
5510
5511 99 return 0;
5512 99 }
5513
5514 108 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5515 {
5516 108 word maxinfos=256;
5517 108 word maxshops=256;
5518 108 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5519 108 word ponds=16, pondsize=72, expansionsize=98*2;
5520 byte tempbyte, padding;
5521 miscQdata temp_misc;
5522 108 word s_version=0, s_cversion=0;
5523 word swaptmp;
5524 108 int32_t tempsize=0;
5525
5526 108 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5527
5528
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxshops; ++i)
5529 {
5530 27648 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5531 27648 }
5532
5533
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxinfos; ++i)
5534 {
5535 27648 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5536 27648 }
5537
5538
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5539 {
5540 //section version info
5541
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
5542 {
5543 return qe_invalid;
5544 }
5545
5546 104 FFCore.quest_format[vMisc] = s_version;
5547
5548 //al_trace("Misc. data version %d\n", s_version);
5549
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
5550 {
5551 return qe_invalid;
5552 }
5553
5554
5555 //section size
5556
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&tempsize,f,true))
5557 {
5558 return qe_invalid;
5559 }
5560 104 }
5561
5562 //finally... section data
5563 108 readsize=0;
5564
5565 //shops
5566
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5567 {
5568
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&shops,f,true))
5569 {
5570 return qe_invalid;
5571 }
5572 104 }
5573
5574
2/2
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 108 times.
1251 for(int32_t i=0; i<shops; i++)
5575 {
5576
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1025 times.
1143 if(s_version > 6)
5577 {
5578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1025 times.
1025 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5579 {
5580 return qe_invalid;
5581 }
5582 1025 }
5583
5584
2/2
✓ Branch 0 taken 3429 times.
✓ Branch 1 taken 1143 times.
4572 for(int32_t j=0; j<3; j++)
5585 {
5586
1/2
✓ Branch 0 taken 3429 times.
✗ Branch 1 not taken.
3429 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5587 {
5588 return qe_invalid;
5589 }
5590
5591
2/2
✓ Branch 0 taken 3075 times.
✓ Branch 1 taken 354 times.
3429 if(s_version < 4)
5592 {
5593 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5594 354 }
5595 3429 }
5596
5597
2/2
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 64 times.
1143 if(Header->zelda_version < 0x193)
5598 {
5599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5600 {
5601 return qe_invalid;
5602 }
5603 64 }
5604
5605
2/2
✓ Branch 0 taken 3429 times.
✓ Branch 1 taken 1143 times.
4572 for(int32_t j=0; j<3; j++)
5606 {
5607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3429 times.
3429 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5608 {
5609 return qe_invalid;
5610 }
5611 3429 }
5612
5613
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1025 times.
1143 if(s_version > 3)
5614 {
5615
2/2
✓ Branch 0 taken 3075 times.
✓ Branch 1 taken 1025 times.
4100 for(int32_t j=0; j<3; j++)
5616 {
5617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3075 times.
3075 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5618 return qe_invalid;
5619 3075 }
5620 1025 }
5621
5622 /*
5623 if(s_version < 8)
5624 {
5625 for(int32_t j=0; j<3; j++)
5626 {
5627 (&temp_misc.shop[i].str[j])=0; //initialise.
5628 }
5629 }
5630 */
5631 1143 }
5632
5633 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5634
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxshops; ++i)
5635 {
5636
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 27648 times.
82944 for(int32_t j=0; j<3-1; j++)
5637 {
5638
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 55296 times.
138240 for(int32_t k=0; k<2-j; k++)
5639 {
5640
2/2
✓ Branch 0 taken 2426 times.
✓ Branch 1 taken 80518 times.
82944 if(temp_misc.shop[i].hasitem[k]==0)
5641 {
5642 80518 swaptmp = temp_misc.shop[i].item[k];
5643 80518 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5644 80518 temp_misc.shop[i].item[k+1] = swaptmp;
5645 80518 swaptmp = temp_misc.shop[i].price[k];
5646 80518 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5647 80518 temp_misc.shop[i].price[k+1] = swaptmp;
5648 80518 swaptmp = temp_misc.shop[i].hasitem[k];
5649 80518 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5650 80518 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5651 80518 }
5652 82944 }
5653 55296 }
5654 27648 }
5655
5656 //infos
5657
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5658 {
5659
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&infos,f,true))
5660 {
5661 return qe_invalid;
5662 }
5663 104 }
5664
5665
2/2
✓ Branch 0 taken 1538 times.
✓ Branch 1 taken 108 times.
1646 for(int32_t i=0; i<infos; i++)
5666 {
5667
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1459 times.
1538 if(s_version > 6)
5668 {
5669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1459 times.
1459 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5670 {
5671 return qe_invalid;
5672 }
5673 1459 }
5674
5675
2/2
✓ Branch 0 taken 4614 times.
✓ Branch 1 taken 1538 times.
6152 for(int32_t j=0; j<3; j++)
5676 {
5677
2/4
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4614 if((Header->zelda_version < 0x192)||
5678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4422 times.
4422 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5679 {
5680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5681 {
5682 return qe_invalid;
5683 }
5684
5685 192 temp_misc.info[i].str[j]=tempbyte;
5686 192 }
5687 else
5688 {
5689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4422 times.
4422 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5690 {
5691 return qe_invalid;
5692 }
5693 }
5694 4614 }
5695
5696
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 64 times.
1538 if(Header->zelda_version < 0x193)
5697 {
5698
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5699 {
5700 return qe_invalid;
5701 }
5702 64 }
5703
5704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1538 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1538 if((Header->zelda_version == 0x192)&&(Header->build>145))
5705 {
5706 if(!p_getc(&padding,f,true))
5707 {
5708 return qe_invalid;
5709 }
5710 }
5711
5712
2/2
✓ Branch 0 taken 4614 times.
✓ Branch 1 taken 1538 times.
6152 for(int32_t j=0; j<3; j++)
5713 {
5714
1/2
✓ Branch 0 taken 4614 times.
✗ Branch 1 not taken.
4614 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5715 {
5716 return qe_invalid;
5717 }
5718 4614 }
5719 1538 }
5720
5721 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5722
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxinfos; ++i)
5723 {
5724
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 27648 times.
82944 for(int32_t j=0; j<3-1; j++)
5725 {
5726
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 55296 times.
138240 for(int32_t k=0; k<2-j; k++)
5727 {
5728
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 81147 times.
82944 if(temp_misc.info[i].str[k]==0)
5729 {
5730 81147 swaptmp = temp_misc.info[i].str[k];
5731 81147 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5732 81147 temp_misc.info[i].str[k+1] = swaptmp;
5733 81147 swaptmp = temp_misc.info[i].price[k];
5734 81147 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5735 81147 temp_misc.info[i].price[k+1] = swaptmp;
5736 81147 }
5737 82944 }
5738 55296 }
5739 27648 }
5740
5741
5742 //warp rings
5743
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version > 5)
5744 99 warprings++;
5745
5746
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5747 {
5748
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&warprings,f,true))
5749 {
5750 return qe_invalid;
5751 }
5752 104 }
5753
5754
2/2
✓ Branch 0 taken 1058 times.
✓ Branch 1 taken 108 times.
1166 for(int32_t i=0; i<warprings; i++)
5755 {
5756
2/2
✓ Branch 0 taken 9410 times.
✓ Branch 1 taken 1058 times.
10468 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5757 {
5758
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 8514 times.
9410 if(s_version <= 3)
5759 {
5760
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,true))
5761 {
5762 return qe_invalid;
5763 }
5764
5765 896 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5766 896 }
5767 else
5768 {
5769
1/2
✓ Branch 0 taken 8514 times.
✗ Branch 1 not taken.
8514 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5770 {
5771 return qe_invalid;
5772 }
5773 }
5774 9410 }
5775
5776
2/2
✓ Branch 0 taken 9410 times.
✓ Branch 1 taken 1058 times.
10468 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5777 {
5778
1/2
✓ Branch 0 taken 9410 times.
✗ Branch 1 not taken.
9410 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5779 {
5780 return qe_invalid;
5781 }
5782 9410 }
5783
5784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
1058 if(!p_getc(&temp_misc.warp[i].size,f,true))
5785 {
5786 return qe_invalid;
5787 }
5788
5789
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 32 times.
1058 if(Header->zelda_version < 0x193)
5790 {
5791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5792 {
5793 return qe_invalid;
5794 }
5795 32 }
5796 1058 }
5797
5798 //palette cycles
5799
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5800 {
5801
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5802 {
5803
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5804 {
5805 3072 temp_misc.cycles[i][j].first=0;
5806 3072 temp_misc.cycles[i][j].count=0;
5807 3072 temp_misc.cycles[i][j].speed=0;
5808 3072 }
5809 1024 }
5810
5811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5812 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5813 {
5814 4 palcycles=16;
5815 4 }
5816
5817
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5818 {
5819
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5820 {
5821
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5822 {
5823 return qe_invalid;
5824 }
5825
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5827 {
5828 return qe_invalid;
5829 }
5830
5831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5832 {
5833 return qe_invalid;
5834 }
5835 192 }
5836 64 }
5837 4 }
5838
5839 //Wind warps are now just another warp ring.
5840
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version <= 5)
5841 {
5842
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5843 {
5844
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5845 {
5846 return qe_invalid;
5847 }
5848 5 }
5849
5850
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5851 {
5852
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5853 {
5854
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5855 {
5856 return qe_invalid;
5857 }
5858
5859 79 temp_misc.warp[8].dmap[i]=tempbyte;
5860 79 }
5861 else
5862 {
5863 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5864 {
5865 return qe_invalid;
5866 }
5867 }
5868
5869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5870 {
5871 return qe_invalid;
5872 }
5873
5874 79 temp_misc.warp[8].size = 9;
5875
5876
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5877 {
5878 if(!p_getc(&tempbyte,f,true))
5879 {
5880 return qe_invalid;
5881 }
5882 }
5883 79 }
5884 9 }
5885
5886
5887 //triforce pieces
5888
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<triforces; i++)
5889 {
5890
1/2
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
864 if(!p_getc(&temp_misc.triforce[i],f,true))
5891 {
5892 return qe_invalid;
5893 }
5894 864 }
5895
5896 //misc color data
5897
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<3)
5898 {
5899
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5900 {
5901 return qe_invalid;
5902 }
5903
5904
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5905 {
5906 return qe_invalid;
5907 }
5908
5909
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5910 {
5911 return qe_invalid;
5912 }
5913
5914
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5915 {
5916 return qe_invalid;
5917 }
5918
5919
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5925 {
5926 return qe_invalid;
5927 }
5928
5929
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5930 {
5931 return qe_invalid;
5932 }
5933
5934
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5935 {
5936 return qe_invalid;
5937 }
5938
5939
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
6005 {
6006 return qe_invalid;
6007 }
6008
6009
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
6010 {
6011 return qe_invalid;
6012 }
6013
6014
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
6015 {
6016 return qe_invalid;
6017 }
6018
6019
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
6020 {
6021 return qe_invalid;
6022 }
6023
6024
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
6025 {
6026 return qe_invalid;
6027 }
6028
6029
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
6030 {
6031 return qe_invalid;
6032 }
6033
6034 9 temp_misc.colors.msgtext = 0x01;
6035
6036
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
6037 {
6038
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6039 {
6040
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6041 {
6042 return qe_invalid;
6043 }
6044 28 }
6045 4 }
6046
6047
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6048 {
6049 for(int32_t i=0; i<256; i++)
6050 {
6051 if(!p_getc(&tempbyte,f,true))
6052 {
6053 return qe_invalid;
6054 }
6055 }
6056 }
6057
6058
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6059 {
6060 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6061 {
6062 return qe_invalid;
6063 }
6064 }
6065
6066 //save game icons
6067
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6069 {
6070 4 icons=3;
6071 4 }
6072
6073
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6074 {
6075
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6076 {
6077 return qe_invalid;
6078 }
6079 32 }
6080 9 }
6081
6082
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
6083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6084 {
6085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6086 {
6087 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6088 4 }
6089
6090 4 return 0;
6091 }
6092
6093 //pond information
6094
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
6095 {
6096 if((Header->zelda_version == 0x192)&&(Header->build<146))
6097 {
6098 pondsize=25;
6099 }
6100
6101 for(int32_t i=0; i<ponds; i++)
6102 {
6103 for(int32_t j=0; j<pondsize; j++)
6104 {
6105 if(!p_getc(&tempbyte,f,true))
6106 {
6107 return qe_invalid;
6108
6109 }
6110 }
6111 }
6112 }
6113
6114 //end string
6115
1/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version < 0x192)||
6116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6117 {
6118 if(!p_getc(&tempbyte,f,true))
6119 {
6120 return qe_invalid;
6121 }
6122
6123 temp_misc.endstring=tempbyte;
6124
6125 if(!p_getc(&tempbyte,f,true))
6126 {
6127 return qe_invalid;
6128 }
6129 }
6130 else
6131 {
6132
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_misc.endstring,f,true))
6133 {
6134 return qe_invalid;
6135 }
6136 }
6137
6138 //expansion
6139
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
6140 {
6141 if((Header->zelda_version == 0x192)&&(Header->build<73))
6142 {
6143 expansionsize=99*2;
6144 }
6145
6146 for(int32_t i=0; i<expansionsize; i++)
6147 {
6148 if(!p_getc(&tempbyte,f,true))
6149 {
6150 return qe_invalid;
6151 }
6152 }
6153 }
6154 //shops v8
6155
6156
6157
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(s_version >= 8)
6158 {
6159
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 23 times.
359 for(int32_t i=0; i<shops; i++)
6160 {
6161
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t j=0; j<3; j++)
6162 {
6163
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6164 return qe_invalid;
6165 1008 }
6166 336 }
6167 23 }
6168
6169 104 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6170 104 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6171 104 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6172
6173 //v9 includes quest misc[32]
6174
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(s_version >= 9)
6175 {
6176
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 23 times.
759 for ( int32_t q = 0; q < 32; q++ )
6177 {
6178
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6179 return qe_invalid;
6180 736 }
6181
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 23 times.
759 for ( int32_t q = 0; q < 32; q++ )
6182 {
6183
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 736 times.
94944 for ( int32_t j = 0; j < 128; j++ )
6184
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6185 return qe_invalid;
6186 736 }
6187 23 }
6188
6189
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version >= 11 )
6190 {
6191
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6192 return qe_invalid;
6193 23 }
6194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 else if(s_version < 11 )
6195 {
6196 81 temp_misc.zscript_last_compiled_version = -1;
6197 81 }
6198
6199 104 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6200
6201
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version >= 12)
6202 {
6203 byte spr;
6204
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t q = 0; q < sprMAX; ++q)
6205 {
6206
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&spr,f,true))
6207 return qe_invalid;
6208 5888 temp_misc.sprites[q] = spr;
6209 5888 }
6210 23 }
6211 else
6212 {
6213 81 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6214 //temp_misc.sprites[sprFALL] = ;
6215 }
6216
6217
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version >= 13)
6218 {
6219
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 23 times.
1495 for(size_t q = 0; q < 64; ++q)
6220 {
6221 1472 bottletype* bt = &(temp_misc.bottle_types[q]);
6222
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!pfread(bt->name, 32, f, true))
6223 return qe_invalid;
6224
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(size_t j = 0; j < 3; ++j)
6225 {
6226
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if (!p_getc(&(bt->counter[j]), f, true))
6227 return qe_invalid;
6228
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if (!p_igetw(&(bt->amount[j]), f, true))
6229 return qe_invalid;
6230 4416 }
6231
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!p_getc(&(bt->flags), f, true))
6232 return qe_invalid;
6233
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!p_getc(&(bt->next_type), f, true))
6234 return qe_invalid;
6235 1472 }
6236
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(size_t q = 0; q < 256; ++q)
6237 {
6238 5888 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6239
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if (!pfread(bst->name, 32, f, true))
6240 return qe_invalid;
6241
2/2
✓ Branch 0 taken 17664 times.
✓ Branch 1 taken 5888 times.
23552 for(size_t j = 0; j < 3; ++j)
6242 {
6243
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_getc(&(bst->fill[j]), f, true))
6244 return qe_invalid;
6245
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->comb[j]), f, true))
6246 return qe_invalid;
6247
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_getc(&(bst->cset[j]), f, true))
6248 return qe_invalid;
6249
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->price[j]), f, true))
6250 return qe_invalid;
6251
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->str[j]), f, true))
6252 return qe_invalid;
6253 17664 }
6254 5888 }
6255 23 }
6256 else
6257 {
6258
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 81 times.
5265 for(size_t q = 0; q < 64; ++q)
6259 5184 temp_misc.bottle_types[q].clear();
6260
2/2
✓ Branch 0 taken 20736 times.
✓ Branch 1 taken 81 times.
20817 for(size_t q = 0; q < 256; ++q)
6261 20736 temp_misc.bottle_shop_types[q].clear();
6262 }
6263
6264
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version >= 14)
6265 {
6266 byte msfx;
6267
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t q = 0; q < sfxMAX; ++q)
6268 {
6269
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&msfx,f,true))
6270 return qe_invalid;
6271 5888 temp_misc.miscsfx[q] = msfx;
6272 5888 }
6273 23 }
6274 else
6275 {
6276 81 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6277 81 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6278 81 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6279 }
6280
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version < 15)
6281 {
6282 81 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6283 81 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6284 81 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6285 81 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6286 81 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6287 81 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6288 81 }
6289
6290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
6291 {
6292 104 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6293 104 }
6294
6295 104 return 0;
6296 108 }
6297
6298 extern char *item_string[ITEMCNT];
6299 extern const char *old_item_string[iLast];
6300 extern char *weapon_string[WPNCNT];
6301 extern const char *old_weapon_string[wLast];
6302
6303 108 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6304 {
6305 byte padding;
6306 int32_t dummy;
6307 108 word items_to_read=MAXITEMS;
6308 itemdata tempitem;
6309 108 word s_version=0, s_cversion=0;
6310 word dummy_word;
6311
6312
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(version < 0x186)
6313 {
6314 items_to_read=64;
6315 }
6316
6317
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
6318 {
6319 104 items_to_read=0;
6320
6321 //section version info
6322
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
6323 {
6324 return qe_invalid;
6325 }
6326
6327 104 FFCore.quest_format[vItems] = s_version;
6328
6329 //al_trace("Items version %d\n", s_version);
6330
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
6331 {
6332 return qe_invalid;
6333 }
6334
6335 //section size
6336
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
6337 {
6338 return qe_invalid;
6339 }
6340
6341 //finally... section data
6342
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&items_to_read,f,true))
6343 {
6344 return qe_invalid;
6345 }
6346 104 }
6347
6348
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version>1)
6349 {
6350
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<items_to_read; i++)
6351 {
6352 char tempname[64];
6353
6354
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!pfread(tempname, 64, f, keepdata))
6355 {
6356 return qe_invalid;
6357 }
6358
6359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(keepdata)
6360 {
6361 25344 strcpy(item_string[i], tempname);
6362 25344 }
6363 25344 }
6364 99 }
6365 else
6366 {
6367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6368 {
6369
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6370 {
6371 2304 reset_itemname(i);
6372 2304 }
6373 9 }
6374 }
6375
6376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
6377 {
6378
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMS; i++)
6379 {
6380 27648 itemdata& id = itemsbuf[i];
6381 27648 memset(&id, 0, sizeof(itemdata));
6382 27648 id.count=-1;
6383 27648 id.playsound=WAV_SCALE;
6384 27648 reset_itembuf(&id,i);
6385 27648 }
6386 108 }
6387
6388
2/2
✓ Branch 0 taken 26718 times.
✓ Branch 1 taken 108 times.
26826 for(int32_t i=0; i<items_to_read; i++)
6389 {
6390 26718 memset(&tempitem, 0, sizeof(itemdata));
6391 26718 reset_itembuf(&tempitem,i);
6392
6393
6394
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20830 times.
26718 if ( s_version > 35 ) //expanded tiles
6395 {
6396
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tile,f,true))
6397 {
6398 return qe_invalid;
6399 }
6400 5888 }
6401 else
6402 {
6403
1/2
✓ Branch 0 taken 20830 times.
✗ Branch 1 not taken.
20830 if(!p_igetw(&tempitem.tile,f,true))
6404 {
6405 return qe_invalid;
6406 }
6407 }
6408
6409
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.misc_flags,f,true))
6410 {
6411 return qe_invalid;
6412 }
6413
6414
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.csets,f,true))
6415 {
6416 return qe_invalid;
6417 }
6418
6419
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.frames,f,true))
6420 {
6421 return qe_invalid;
6422 }
6423
6424
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.speed,f,true))
6425 {
6426 return qe_invalid;
6427 }
6428
6429
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.delay,f,true))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
2/2
✓ Branch 0 taken 25694 times.
✓ Branch 1 taken 1024 times.
26718 if(version < 0x193)
6435 {
6436
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6437 {
6438 return qe_invalid;
6439 }
6440
6441
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6442 {
6443
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6444 {
6445 case iShield:
6446 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6447 4 break;
6448
6449 case iMShield:
6450 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6451 4 break;
6452
6453 default:
6454 1016 tempitem.ltm=0;
6455 1016 break;
6456 }
6457
6458 1024 tempitem.count=-1;
6459 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6460 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6461 1024 tempitem.family=0xFF;
6462 1024 tempitem.playsound=WAV_SCALE;
6463 1024 reset_itembuf(&tempitem,i);
6464
6465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6466 {
6467 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6468 1024 }
6469
6470 1024 continue;
6471 }
6472 }
6473
6474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25694 times.
25694 if(!p_igetl(&tempitem.ltm,f,true))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(version < 0x193)
6480 {
6481 for(int32_t q=0; q<12; q++)
6482 {
6483 if(!p_getc(&padding,f,true))
6484 {
6485 return qe_invalid;
6486 }
6487 }
6488 }
6489
6490
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 350 times.
25694 if(s_version>1)
6491 {
6492
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 19456 times.
25344 if ( s_version >= 31 )
6493 {
6494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.family,f,true))
6495 {
6496 return qe_invalid;
6497 }
6498 5888 }
6499 else
6500 {
6501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.family,f,true))
6502 {
6503 return qe_invalid;
6504 }
6505 }
6506
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version < 16)
6507 if(tempitem.family == 0xFF)
6508 tempitem.family = itype_misc;
6509
6510
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.fam_type,f,true))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version>5)
6516 {
6517
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 19456 times.
25344 if(s_version>=31)
6518 {
6519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.power,f,true))
6520 {
6521 return qe_invalid;
6522 }
6523 5888 }
6524 else
6525 {
6526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.power,f,true))
6527 {
6528 return qe_invalid;
6529 }
6530 }
6531
6532 //converted flags from 16b to 32b -Z
6533
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version < 41 )
6534 {
6535
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&tempitem.flags,f,true))
6536 {
6537 return qe_invalid;
6538 }
6539 19456 }
6540 else
6541 {
6542
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.flags,f,true))
6543 {
6544 return qe_invalid;
6545 }
6546 }
6547 25344 }
6548 else
6549 {
6550 //tempitem.power = tempitem.fam_type;
6551 char tempchar;
6552
6553 if(!p_getc(&tempchar,f,true))
6554 {
6555 return qe_invalid;
6556 }
6557
6558 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6559 }
6560
6561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.script,f,true))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<=3)
6567 {
6568 if(tempitem.script > NUMSCRIPTITEM)
6569 {
6570 tempitem.script = 0;
6571 }
6572 }
6573
6574
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.count,f,true))
6575 {
6576 return qe_invalid;
6577 }
6578
6579
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetw(&tempitem.amount,f,true))
6580 {
6581 return qe_invalid;
6582 }
6583
6584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.collect_script,f,true))
6585 {
6586 return qe_invalid;
6587 }
6588
6589
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<=3)
6590 {
6591 if(tempitem.collect_script > NUMSCRIPTITEM)
6592 {
6593 tempitem.collect_script = 0;
6594 }
6595 }
6596
6597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.setmax,f,true))
6598 {
6599 return qe_invalid;
6600 }
6601
6602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.max,f,true))
6603 {
6604 return qe_invalid;
6605 }
6606
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.playsound,f,true))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
2/2
✓ Branch 0 taken 202752 times.
✓ Branch 1 taken 25344 times.
228096 for(int32_t j=0; j<8; j++)
6613 {
6614
1/2
✓ Branch 0 taken 202752 times.
✗ Branch 1 not taken.
202752 if(!p_igetl(&tempitem.initiald[j],f,true))
6615 {
6616 return qe_invalid;
6617 }
6618 202752 }
6619
6620
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<2; j++)
6621 {
6622
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempitem.initiala[j],f,true))
6623 {
6624 return qe_invalid;
6625 }
6626 50688 }
6627
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>4)
6629 {
6630
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version>5)
6631 {
6632
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn,f,true))
6633 {
6634 return qe_invalid;
6635 }
6636
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn2,f,true))
6638 {
6639 return qe_invalid;
6640 }
6641
6642
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn3,f,true))
6643 {
6644 return qe_invalid;
6645 }
6646
6647
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn4,f,true))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>=15)
6653 {
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn5,f,true))
6655 {
6656 return qe_invalid;
6657 }
6658
6659
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn6,f,true))
6660 {
6661 return qe_invalid;
6662 }
6663
6664
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn7,f,true))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn8,f,true))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn9,f,true))
6675 {
6676 return qe_invalid;
6677 }
6678
6679
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn10,f,true))
6680 {
6681 return qe_invalid;
6682 }
6683 25344 }
6684
6685
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.pickup_hearts,f,true))
6686 {
6687 return qe_invalid;
6688 }
6689
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version<15)
6691 {
6692 if(!p_igetw(&dummy_word,f,true))
6693 {
6694 return qe_invalid;
6695 }
6696
6697 tempitem.misc1=dummy_word;
6698
6699 if(!p_igetw(&dummy_word,f,true))
6700 {
6701 return qe_invalid;
6702 }
6703
6704 tempitem.misc2=dummy_word;
6705 }
6706 else
6707 {
6708
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc1,f,true))
6709 {
6710 return qe_invalid;
6711 }
6712
6713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc2,f,true))
6714 {
6715 return qe_invalid;
6716 }
6717
6718 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6719
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<24)
6720 {
6721 if(tempitem.family==itype_shield)
6722 {
6723 tempitem.misc1|=shSCRIPT;
6724 }
6725 }
6726 }
6727
6728
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if(s_version < 53)
6729 {
6730 byte tempbyte;
6731
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempbyte,f,true))
6732 {
6733 return qe_invalid;
6734 }
6735 19456 tempitem.cost_amount[0] = tempbyte;
6736 19456 }
6737 else
6738 {
6739
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < 2; ++q)
6740 {
6741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6742 {
6743 return qe_invalid;
6744 }
6745 11776 }
6746 }
6747 25344 }
6748 else
6749 {
6750 char tempchar;
6751
6752 if(!p_getc(&tempchar,f,true))
6753 {
6754 return qe_invalid;
6755 }
6756
6757 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6758 }
6759
6760 // June 2007: more misc. attributes
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>=12)
6762 {
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version<15)
6764 {
6765 if(!p_igetw(&dummy_word,f,true))
6766 {
6767 return qe_invalid;
6768 }
6769
6770 tempitem.misc3=dummy_word;
6771
6772 if(!p_igetw(&dummy_word,f,true))
6773 {
6774 return qe_invalid;
6775 }
6776
6777 tempitem.misc4=dummy_word;
6778 }
6779 else
6780 {
6781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc3,f,true))
6782 {
6783 return qe_invalid;
6784 }
6785
6786
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc4,f,true))
6787 {
6788 return qe_invalid;
6789 }
6790
6791
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc5,f,true))
6792 {
6793 return qe_invalid;
6794 }
6795
6796
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc6,f,true))
6797 {
6798 return qe_invalid;
6799 }
6800
6801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc7,f,true))
6802 {
6803 return qe_invalid;
6804 }
6805
6806
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc8,f,true))
6807 {
6808 return qe_invalid;
6809 }
6810
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc9,f,true))
6812 {
6813 return qe_invalid;
6814 }
6815
6816
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc10,f,true))
6817 {
6818 return qe_invalid;
6819 }
6820 }
6821
6822
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.usesound,f,true))
6823 {
6824 return qe_invalid;
6825 }
6826
6827
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 19456 times.
25344 if(s_version >= 49)
6828 {
6829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_getc(&tempitem.usesound2,f,true))
6830 {
6831 return qe_invalid;
6832 }
6833 5888 }
6834 19456 else tempitem.usesound2 = 0;
6835
6836
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
25344 if(s_version < 50 && tempitem.family == itype_mirror)
6837 {
6838 //Split continue/dmap warp effect/sfx, port for old
6839 tempitem.misc2 = tempitem.misc1;
6840 tempitem.usesound2 = tempitem.usesound;
6841 }
6842 25344 }
6843 25344 }
6844
6845
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6846 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_getc(&tempitem.useweapon,f,true))
6848 {
6849 return qe_invalid;
6850 }
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_getc(&tempitem.usedefence,f,true))
6852 {
6853 return qe_invalid;
6854 }
6855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weaprange,f,true))
6856 {
6857 return qe_invalid;
6858 }
6859
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weapduration,f,true))
6860 {
6861 return qe_invalid;
6862 }
6863
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 5888 times.
64768 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6864 {
6865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
58880 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6866 {
6867 return qe_invalid;
6868 }
6869 58880 }
6870 5888 }
6871
6872
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6873 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6874
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.duplicates,f,true))
6875 {
6876 return qe_invalid;
6877 }
6878
2/2
✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 5888 times.
52992 for ( int32_t q = 0; q < INITIAL_D; q++ )
6879 {
6880
1/2
✓ Branch 0 taken 47104 times.
✗ Branch 1 not taken.
47104 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6881 {
6882 return qe_invalid;
6883 }
6884 47104 }
6885
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for ( int32_t q = 0; q < INITIAL_A; q++ )
6886 {
6887
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6888 {
6889 return qe_invalid;
6890 }
6891 11776 }
6892
6893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_getc(&tempitem.drawlayer,f,true))
6894 {
6895 return qe_invalid;
6896 }
6897
6898
6899
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hxofs,f,true))
6900 {
6901 return qe_invalid;
6902 }
6903
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hyofs,f,true))
6904 {
6905 return qe_invalid;
6906 }
6907
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hxsz,f,true))
6908 {
6909 return qe_invalid;
6910 }
6911
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hysz,f,true))
6912 {
6913 return qe_invalid;
6914 }
6915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.hzsz,f,true))
6916 {
6917 return qe_invalid;
6918 }
6919
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.xofs,f,true))
6920 {
6921 return qe_invalid;
6922 }
6923
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.yofs,f,true))
6924 {
6925 return qe_invalid;
6926 }
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6928 {
6929 return qe_invalid;
6930 }
6931
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6932 {
6933 return qe_invalid;
6934 }
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6936 {
6937 return qe_invalid;
6938 }
6939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weap_hysz,f,true))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weap_xofs,f,true))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_yofs,f,true))
6952 {
6953 return qe_invalid;
6954 }
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetw(&tempitem.weaponscript,f,true))
6956 {
6957 return qe_invalid;
6958 }
6959
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.wpnsprite,f,true))
6960 {
6961 return qe_invalid;
6962 }
6963 5888 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6964
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < num_cost_tmr; ++q)
6965 {
6966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6967 {
6968 return qe_invalid;
6969 }
6970 11776 }
6971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 for(auto q = num_cost_tmr; q < 2; ++q)
6972 tempitem.magiccosttimer[q] = 0;
6973 5888 }
6974
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6975 {
6976 //Item Size FLags, TileWidth, TileHeight
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6978 {
6979 return qe_invalid;
6980 }
6981
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tilew,f,true))
6982 {
6983 return qe_invalid;
6984 }
6985
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tileh,f,true))
6986 {
6987 return qe_invalid;
6988 }
6989 5888 }
6990
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 29 ) //! More new vars.
6991 {
6992 //Item Size FLags, TileWidth, TileHeight
6993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6994 {
6995 return qe_invalid;
6996 }
6997
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_tilew,f,true))
6998 {
6999 return qe_invalid;
7000 }
7001
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_tileh,f,true))
7002 {
7003 return qe_invalid;
7004 }
7005 5888 }
7006
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 30 ) //! More new vars.
7007 {
7008 //Pickup Type
7009
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.pickup,f,true))
7010 {
7011 return qe_invalid;
7012 }
7013 5888 }
7014
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 32 ) //! More new vars.
7015 {
7016 //Pickup Type
7017
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.pstring,f,true))
7018 {
7019 return qe_invalid;
7020 }
7021 5888 }
7022
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 33 ) //! More new vars.
7023 {
7024 //Pickup Type
7025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
7026 {
7027 return qe_invalid;
7028 }
7029 5888 }
7030
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 34 ) //! cost counter
7031 {
7032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(s_version < 53)
7033 {
7034 if(!p_getc(&tempitem.cost_counter[0],f,true))
7035 {
7036 return qe_invalid;
7037 }
7038 }
7039 else
7040 {
7041
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < 2; ++q)
7042 {
7043
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempitem.cost_counter[q],f,true))
7044 {
7045 return qe_invalid;
7046 }
7047 11776 }
7048 }
7049 5888 }
7050
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 44 ) //! sprite scripts
7051 {
7052
2/2
✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 5888 times.
52992 for ( int32_t q = 0; q < 8; q++ )
7053 {
7054
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
7055 {
7056
1/2
✓ Branch 0 taken 3061760 times.
✗ Branch 1 not taken.
3061760 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7057 {
7058 return qe_invalid;
7059 }
7060 3061760 }
7061
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
7062 {
7063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061760 times.
3061760 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7064 {
7065 return qe_invalid;
7066 }
7067 3061760 }
7068
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
7069 {
7070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061760 times.
3061760 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7071 {
7072 return qe_invalid;
7073 }
7074 3061760 }
7075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47104 times.
47104 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7076 {
7077 return qe_invalid;
7078 }
7079
7080 47104 }
7081
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for ( int32_t q = 0; q < 2; q++ )
7082 {
7083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7084 {
7085 return qe_invalid;
7086 }
7087 11776 }
7088 //Pickup Type
7089
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.sprite_script,f,true))
7090 {
7091 return qe_invalid;
7092 }
7093 5888 }
7094
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 5888 times.
25344 if ( s_version >= 48 ) //! pickup flags
7095 {
7096
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7097 {
7098 return qe_invalid;
7099 }
7100 5888 }
7101
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 2048 times.
25344 if ( s_version >= 57 )
7102 {
7103 2048 std::string str;
7104
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
2048 if(!p_getcstr(&str,f,true))
7105 return qe_invalid;
7106 2048 strncpy(tempitem.display_name,str.c_str(),255);
7107
1/3
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2048 }
7108 25344 }
7109 else
7110 {
7111 350 tempitem.count=-1;
7112 350 tempitem.family=itype_misc;
7113 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7114 350 tempitem.playsound=WAV_SCALE;
7115 350 reset_itembuf(&tempitem,i);
7116 }
7117
7118
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(keepdata==true)
7119 {
7120 25694 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7121 25694 }
7122 else if(zgpmode)
7123 {
7124 itemsbuf[i].tile=tempitem.tile;
7125 itemsbuf[i].misc_flags=tempitem.misc_flags;
7126 itemsbuf[i].csets=tempitem.csets;
7127 itemsbuf[i].frames=tempitem.frames;
7128 itemsbuf[i].speed=tempitem.speed;
7129 itemsbuf[i].delay=tempitem.delay;
7130 itemsbuf[i].ltm=tempitem.ltm;
7131 }
7132 25694 }
7133
7134 //////////////////////////////////////////////////////
7135 // Now do any updates because of new item additions
7136 // (These can't be done above because items_to_read
7137 // might be too low.)
7138 //////////////////////////////////////////////////////
7139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
7140 {
7141
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMS; i++)
7142 {
7143 27648 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7144
7145 //Account for older quests that didn't have an actual item for the used letter
7146
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 2 && i==iLetterUsed)
7147 {
7148 9 reset_itembuf(&tempitem, iLetterUsed);
7149 9 strcpy(item_string[i],old_item_string[i]);
7150 9 tempitem.tile = itemsbuf[iLetter].tile;
7151 9 tempitem.csets = itemsbuf[iLetter].csets;
7152 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7153 9 tempitem.frames = itemsbuf[iLetter].frames;
7154 9 tempitem.speed = itemsbuf[iLetter].speed;
7155 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7156 9 }
7157
7158
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 3)
7159 {
7160
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7161 {
7162 case iRocsFeather:
7163 case iHoverBoots:
7164 case iSpinScroll:
7165 case iL2SpinScroll:
7166 case iCrossScroll:
7167 case iQuakeScroll:
7168 case iL2QuakeScroll:
7169 case iWhispRing:
7170 case iL2WhispRing:
7171 case iChargeRing:
7172 case iL2ChargeRing:
7173 case iPerilScroll:
7174 case iWalletL3:
7175 case iQuiverL4:
7176 case iBombBagL4:
7177 case iBracelet:
7178 case iL2Bracelet:
7179 case iOldGlove:
7180 case iL2Ladder:
7181 case iWealthMedal:
7182 case iL2WealthMedal:
7183 case iL3WealthMedal:
7184 198 reset_itembuf(&tempitem, i);
7185 198 strcpy(item_string[i],old_item_string[i]);
7186 198 break;
7187
7188 case iSShield:
7189 9 reset_itembuf(&tempitem, i);
7190 9 strcpy(item_string[i],old_item_string[i]);
7191 9 strcpy(item_string[iShield],old_item_string[iShield]);
7192 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7193 9 break;
7194 }
7195 2304 }
7196
7197
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 5)
7198 {
7199
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7200 {
7201 case iHeartRing:
7202 case iL2HeartRing:
7203 case iL3HeartRing:
7204 case iMagicRing:
7205 case iL2MagicRing:
7206 case iL3MagicRing:
7207 case iL4MagicRing:
7208 63 reset_itembuf(&tempitem, i);
7209 63 strcpy(item_string[i],old_item_string[i]);
7210 63 break;
7211 }
7212 2304 }
7213
7214
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7215 {
7216
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7217 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7218
7219
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7220 {
7221 case iTriforce:
7222 9 tempitem.fam_type=1;
7223 9 break;
7224
7225 case iBigTri:
7226 9 tempitem.fam_type=0;
7227 9 break;
7228
7229 case iBombs:
7230 9 tempitem.fam_type=i_bomb;
7231 9 tempitem.power=4;
7232 9 tempitem.wpn=wBOMB;
7233 9 tempitem.wpn2=wBOOM;
7234 9 tempitem.misc1 = 50;
7235
7236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7237
7238 9 break;
7239
7240 case iSBomb:
7241 9 tempitem.fam_type=i_sbomb;
7242 9 tempitem.power=16;
7243 9 tempitem.wpn=wSBOMB;
7244 9 tempitem.wpn2=wSBOOM;
7245 9 tempitem.misc1 = 50;
7246
7247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7248
7249 9 break;
7250
7251 case iBook:
7252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 113))
7253 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7254
7255 9 break;
7256
7257 case iSArrow:
7258 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7259 9 tempitem.power=4;
7260 9 tempitem.flags|=ITEM_GAMEDATA;
7261 9 tempitem.wpn=wSARROW;
7262 9 break;
7263
7264 case iGArrow:
7265 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7266 9 tempitem.power=8;
7267 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7268 9 tempitem.wpn=wGARROW;
7269 9 break;
7270
7271 case iBrang:
7272 9 tempitem.power=0;
7273 9 tempitem.wpn=wBRANG;
7274 9 tempitem.misc1=36;
7275 9 break;
7276
7277 case iMBrang:
7278 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7279 9 tempitem.power=0;
7280 9 tempitem.wpn=wMBRANG;
7281 9 break;
7282
7283 case iFBrang:
7284 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7285 9 tempitem.power=2;
7286 9 tempitem.wpn=wFBRANG;
7287 9 break;
7288
7289 case iBoots:
7290 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7291 9 tempitem.power=7;
7292 9 break;
7293
7294 case iWand:
7295 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7296 9 tempitem.power=2;
7297 9 tempitem.wpn=wWAND;
7298 9 tempitem.wpn3=wMAGIC;
7299 9 break;
7300
7301 case iBCandle:
7302 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7303 9 tempitem.power=1;
7304 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7305 9 tempitem.wpn3=wFIRE;
7306 9 break;
7307
7308 case iRCandle:
7309 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7310 9 tempitem.power=1;
7311 9 tempitem.wpn3=wFIRE;
7312 9 break;
7313
7314 case iSword:
7315 9 tempitem.power=1;
7316 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7317 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7318 9 tempitem.wpn2=wSWORDSLASH;
7319 9 break;
7320
7321 case iWSword:
7322 9 tempitem.power=2;
7323 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7324 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7325 9 tempitem.wpn2=wWSWORDSLASH;
7326 9 break;
7327
7328 case iMSword:
7329 9 tempitem.power=4;
7330 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7331 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7332 9 tempitem.wpn2=wMSWORDSLASH;
7333 9 break;
7334
7335 case iXSword:
7336 9 tempitem.power=8;
7337 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7338 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7339 9 tempitem.wpn2=wXSWORDSLASH;
7340 9 break;
7341
7342 case iDivineProtection:
7343 9 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7344 9 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7345 9 tempitem.wpn=wDIVINEPROTECTION1A;
7346 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7347 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7348 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7349 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7350 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7351 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7352 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7353 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7354 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7355 9 tempitem.misc1=512;
7356 9 tempitem.cost_amount[0]=64;
7357 9 break;
7358
7359 case iLens:
7360 9 tempitem.misc1=60;
7361 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7362 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7363 9 break;
7364
7365 case iArrow:
7366 9 tempitem.power=2;
7367 9 tempitem.wpn=wARROW;
7368 9 break;
7369
7370 case iHoverBoots:
7371 9 tempitem.misc1=45;
7372 9 tempitem.wpn=iwHover;
7373 9 break;
7374
7375 case iDivineFire:
7376 9 tempitem.power=8;
7377 9 tempitem.wpn=wDIVINEFIRE1A;
7378 9 tempitem.wpn2=wDIVINEFIRE1B;
7379 9 tempitem.wpn3=wDIVINEFIRES1A;
7380 9 tempitem.wpn4=wDIVINEFIRES1B;
7381 9 tempitem.misc1 = 32;
7382 9 tempitem.misc2 = 200;
7383 9 tempitem.cost_amount[0]=32;
7384 9 break;
7385
7386 case iDivineEscape:
7387 9 tempitem.cost_amount[0]=32;
7388 9 break;
7389
7390 case iHookshot:
7391 9 tempitem.power=0;
7392 9 tempitem.flags&=~ITEM_FLAG1;
7393 9 tempitem.wpn=wHSHEAD;
7394 9 tempitem.wpn2=wHSCHAIN_H;
7395 9 tempitem.wpn4=wHSHANDLE;
7396 9 tempitem.wpn3=wHSCHAIN_V;
7397 9 tempitem.misc1=50;
7398 9 tempitem.misc2=100;
7399 9 break;
7400
7401 case iLongshot:
7402 9 tempitem.power=0;
7403 9 tempitem.flags&=~ITEM_FLAG1;
7404 9 tempitem.wpn=wLSHEAD;
7405 9 tempitem.wpn2=wLSCHAIN_H;
7406 9 tempitem.wpn4=wLSHANDLE;
7407 9 tempitem.wpn3=wLSCHAIN_V;
7408 9 tempitem.misc1=99;
7409 9 tempitem.misc2=100;
7410 9 break;
7411
7412 case iHammer:
7413 9 tempitem.power=4;
7414 9 tempitem.wpn=wHAMMER;
7415 9 tempitem.wpn2=iwHammerSmack;
7416 9 break;
7417
7418 case iCByrna:
7419 9 tempitem.power=1;
7420 9 tempitem.wpn=wCBYRNA;
7421 9 tempitem.wpn2=wCBYRNASLASH;
7422 9 tempitem.wpn3=wCBYRNAORB;
7423 9 tempitem.misc1=4;
7424 9 tempitem.misc2=16;
7425 9 tempitem.misc3=1;
7426 9 tempitem.cost_amount[0]=1;
7427 9 break;
7428
7429 case iWhistle:
7430 9 tempitem.wpn=wWIND;
7431 9 tempitem.misc1=3;
7432 9 tempitem.flags|=ITEM_FLAG1;
7433 9 break;
7434
7435 case iBRing:
7436 9 tempitem.power=2;
7437 9 tempitem.misc1=spBLUE;
7438 9 break;
7439
7440 case iRRing:
7441 9 tempitem.power=4;
7442 9 tempitem.misc1=spRED;
7443 9 break;
7444
7445 case iGRing:
7446 9 tempitem.power=8;
7447 9 tempitem.misc1=spGOLD;
7448 9 break;
7449
7450 case iSpinScroll:
7451 9 tempitem.power = 2;
7452 9 tempitem.misc1 = 1;
7453 9 break;
7454
7455 case iL2SpinScroll:
7456 9 tempitem.family=itype_spinscroll2;
7457 9 tempitem.fam_type=1;
7458 9 tempitem.cost_amount[0]=8;
7459 9 tempitem.power=2;
7460 9 tempitem.misc1 = 20;
7461 9 break;
7462
7463 case iQuakeScroll:
7464 9 tempitem.misc1=0x10;
7465 9 tempitem.misc2=64;
7466 9 break;
7467
7468 case iL2QuakeScroll:
7469 9 tempitem.family=itype_quakescroll2;
7470 9 tempitem.fam_type=1;
7471 9 tempitem.power = 2;
7472 9 tempitem.misc1=0x20;
7473 9 tempitem.misc2=192;
7474 9 tempitem.cost_amount[0]=8;
7475 9 break;
7476
7477 case iChargeRing:
7478 9 tempitem.misc1=64;
7479 9 tempitem.misc2=128;
7480 9 break;
7481
7482 case iL2ChargeRing:
7483 9 tempitem.misc1=32;
7484 9 tempitem.misc2=64;
7485 9 break;
7486
7487 case iOldGlove:
7488 9 tempitem.flags |= ITEM_FLAG1;
7489
7490 //fallthrough
7491 case iBombBagL4:
7492 case iWalletL3:
7493 case iQuiverL4:
7494 case iBracelet:
7495 45 tempitem.power = 1;
7496 45 break;
7497
7498 case iL2Bracelet:
7499 9 tempitem.power = 2;
7500 9 break;
7501
7502 case iMKey:
7503 9 tempitem.power=0xFF;
7504 9 tempitem.flags |= ITEM_FLAG1;
7505 9 break;
7506 }
7507 2304 }
7508
7509
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 7)
7510 {
7511
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7512 {
7513 case iStoneAgony:
7514 case iStompBoots:
7515 case iPerilRing:
7516 case iWhimsicalRing:
7517 {
7518 36 reset_itembuf(&tempitem, i);
7519 36 strcpy(item_string[i],old_item_string[i]);
7520 36 break;
7521 }
7522 }
7523 2304 }
7524
7525
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 8) // May 2007: Some corrections.
7526 {
7527
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7528 {
7529 case iMShield:
7530 9 tempitem.misc1|=shFLAME;
7531 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7532
7533
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7534 {
7535 tempitem.misc2 |= shSWORD;
7536 }
7537
7538 // fallthrough
7539 case iShield:
7540 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7541
7542 // fallthrough
7543 case iSShield:
7544 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7545
7546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7547 {
7548 tempitem.misc2 |= shROCK;
7549 }
7550
7551 27 break;
7552
7553 case iWhispRing:
7554 9 tempitem.power=1;
7555 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7556 9 tempitem.misc1 = 3;
7557 9 break;
7558
7559 case iL2WhispRing:
7560 9 tempitem.power=0;
7561 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7562 9 tempitem.misc1 = 3;
7563 9 break;
7564
7565 case iL2Ladder:
7566 case iBow:
7567 case iCByrna:
7568 27 tempitem.power = 1;
7569 27 break;
7570 }
7571 2304 }
7572
7573
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 9 && i==iClock)
7574 {
7575 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7576 9 }
7577
7578 //add the misc flag for bomb
7579
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 10 && tempitem.family == itype_bomb)
7580 {
7581 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7582 9 }
7583
7584
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
27648 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7585 {
7586 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7587 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7588 18 }
7589
7590
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 12) // June 2007: More Misc. attributes.
7591 {
7592
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7593 {
7594 case iFBrang:
7595 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7596
7597 //fallthrough
7598 case iMBrang:
7599 18 tempitem.misc3 |= shSWORD|shMAGIC;
7600
7601 //fallthrough
7602 case iHookshot:
7603 case iLongshot:
7604 //fallthrough
7605 36 tempitem.misc3 |= shFIREBALL;
7606
7607 case iBrang:
7608 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7609 45 break;
7610 }
7611
7612
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7613 {
7614 case itype_hoverboots:
7615 9 tempitem.usesound = WAV_ZN1HOVER;
7616 9 break;
7617
7618 case itype_wand:
7619 9 tempitem.usesound = WAV_WAND;
7620 9 break;
7621
7622 case itype_book:
7623 9 tempitem.usesound = WAV_FIRE;
7624 9 break;
7625
7626 case itype_arrow:
7627 27 tempitem.usesound = WAV_ARROW;
7628 27 break;
7629
7630 case itype_hookshot:
7631 18 tempitem.usesound = WAV_HOOKSHOT;
7632 18 break;
7633
7634 case itype_brang:
7635 27 tempitem.usesound = WAV_BRANG;
7636 27 break;
7637
7638 case itype_shield:
7639 27 tempitem.usesound = WAV_CHINK;
7640 27 break;
7641
7642 case itype_sword:
7643 781 tempitem.usesound = WAV_SWORD;
7644 781 break;
7645
7646 case itype_whistle:
7647 9 tempitem.usesound = WAV_WHISTLE;
7648 9 break;
7649
7650 case itype_hammer:
7651 9 tempitem.usesound = WAV_HAMMER;
7652 9 break;
7653
7654 case itype_divinefire:
7655 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7656 9 break;
7657
7658 case itype_divineescape:
7659 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7660 9 break;
7661
7662 case itype_divineprotection:
7663 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7664 9 break;
7665
7666 case itype_bomb:
7667 case itype_sbomb:
7668 case itype_quakescroll:
7669 case itype_quakescroll2:
7670 36 tempitem.usesound = WAV_BOMB;
7671 36 break;
7672
7673 case itype_spinscroll:
7674 case itype_spinscroll2:
7675 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7676 18 break;
7677 }
7678 2304 }
7679
7680
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 13) // July 2007
7681 {
7682
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7683 {
7684 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7685 9 tempitem.power = 1;
7686 9 tempitem.flags|=ITEM_FLAG1;
7687 9 }
7688
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7689 9 tempitem.flags|=ITEM_FLAG1;
7690
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7691 {
7692 9 tempitem.flags|=ITEM_FLAG1;
7693 9 tempitem.power = 2;
7694 9 }
7695 2304 }
7696
7697
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 14) // August 2007
7698 {
7699
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7700 {
7701 18 tempitem.usesound = WAV_SCALE;
7702
7703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7704 18 tempitem.misc3=50;
7705 18 }
7706
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7707 {
7708 18 tempitem.flags |= ITEM_GAINOLD;
7709 18 }
7710 2304 }
7711
7712
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 17) // November 2007
7713 {
7714
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7715 {
7716 tempitem.wpn3 = wFIRE;
7717 }
7718
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7719 {
7720 9 tempitem.flags|=ITEM_FLAG1;
7721 9 }
7722 2304 }
7723
7724
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 18) // New Year's Eve 2007
7725 {
7726
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7727 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7728
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7729 9 tempitem.misc1 = 768; // Frames until it goes
7730
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7731 {
7732
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7733 {
7734 9 tempitem.misc2 = 1; // Cutscene 1
7735 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7736 9 }
7737 18 }
7738 2304 }
7739
7740
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 19) // January 2008
7741 {
7742
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7743 {
7744 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7745 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7746 9 }
7747 2304 }
7748
7749
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 20) // October 2008
7750 {
7751
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7752 {
7753 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7754 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7755 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7756 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7757 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7758 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7759 9 }
7760 2304 }
7761
7762
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 21) // November 2008
7763 {
7764
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7765 {
7766 tempitem.flags &= ~0x0100;
7767
7768 if(tempitem.family == itype_sword ||
7769 tempitem.family == itype_wand ||
7770 tempitem.family == itype_candle ||
7771 tempitem.family == itype_cbyrna)
7772 {
7773 tempitem.flags |= ITEM_FLAG4;
7774 }
7775 }
7776 2304 }
7777
7778
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 22) // September 2009
7779 {
7780
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7781 {
7782 18 tempitem.misc3 = tempitem.power/2;
7783 18 }
7784 2304 }
7785
7786
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 23) // March 2011
7787 {
7788
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7789 9 tempitem.wpn5 = wFIRE;
7790
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7791 9 tempitem.wpn2 = wFIRE;
7792 2304 }
7793
7794 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7795 // whether it was or not, and a lot of existing quests depended on the
7796 // incorrect behavior.
7797
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 25) // January 2012
7798 {
7799
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7800 36 tempitem.flags |= 16;
7801
7802
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7803 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7804 2304 }
7805
7806
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7807 {
7808
60/60
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 85 times.
✓ Branch 6 taken 168 times.
✓ Branch 7 taken 167 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 278 times.
✓ Branch 10 taken 252 times.
✓ Branch 11 taken 167 times.
✓ Branch 12 taken 259 times.
✓ Branch 13 taken 168 times.
✓ Branch 14 taken 84 times.
✓ Branch 15 taken 168 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 84 times.
✓ Branch 18 taken 255 times.
✓ Branch 19 taken 85 times.
✓ Branch 20 taken 86 times.
✓ Branch 21 taken 168 times.
✓ Branch 22 taken 84 times.
✓ Branch 23 taken 85 times.
✓ Branch 24 taken 84 times.
✓ Branch 25 taken 84 times.
✓ Branch 26 taken 84 times.
✓ Branch 27 taken 99 times.
✓ Branch 28 taken 84 times.
✓ Branch 29 taken 85 times.
✓ Branch 30 taken 84 times.
✓ Branch 31 taken 85 times.
✓ Branch 32 taken 168 times.
✓ Branch 33 taken 336 times.
✓ Branch 34 taken 86 times.
✓ Branch 35 taken 84 times.
✓ Branch 36 taken 152 times.
✓ Branch 37 taken 336 times.
✓ Branch 38 taken 84 times.
✓ Branch 39 taken 84 times.
✓ Branch 40 taken 84 times.
✓ Branch 41 taken 84 times.
✓ Branch 42 taken 84 times.
✓ Branch 43 taken 169 times.
✓ Branch 44 taken 168 times.
✓ Branch 45 taken 84 times.
✓ Branch 46 taken 253 times.
✓ Branch 47 taken 254 times.
✓ Branch 48 taken 340 times.
✓ Branch 49 taken 84 times.
✓ Branch 50 taken 84 times.
✓ Branch 51 taken 84 times.
✓ Branch 52 taken 84 times.
✓ Branch 53 taken 84 times.
✓ Branch 54 taken 85 times.
✓ Branch 55 taken 2368 times.
✓ Branch 56 taken 903 times.
✓ Branch 57 taken 253 times.
✓ Branch 58 taken 1047 times.
✓ Branch 59 taken 2617 times.
21760 switch(tempitem.family)
7809 {
7810 case itype_sword:
7811 {
7812 6848 tempitem.flags &= ~(ITEM_FLAG5);
7813 6848 tempitem.misc3 = 0;
7814 6848 tempitem.misc4 = 0;
7815 6848 tempitem.misc5 = 0;
7816 6848 tempitem.misc6 = 0;
7817 6848 tempitem.misc7 = 0;
7818 6848 tempitem.misc8 = 0;
7819 6848 tempitem.misc9 = 0;
7820 6848 tempitem.misc10 = 0;
7821 6848 tempitem.wpn4 = 0;
7822 6848 tempitem.wpn5 = 0;
7823 6848 tempitem.wpn6 = 0;
7824 6848 tempitem.wpn7 = 0;
7825 6848 tempitem.wpn8 = 0;
7826 6848 tempitem.wpn9 = 0;
7827 6848 tempitem.wpn10 = 0;
7828 6848 break;
7829 }
7830 case itype_brang:
7831 {
7832 253 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7833 253 tempitem.misc2 = 0;
7834 253 tempitem.misc5 = 0;
7835 253 tempitem.misc6 = 0;
7836 253 tempitem.misc7 = 0;
7837 253 tempitem.misc8 = 0;
7838 253 tempitem.misc9 = 0;
7839 253 tempitem.misc10 = 0;
7840 253 tempitem.wpn4 = 0;
7841 253 tempitem.wpn5 = 0;
7842 253 tempitem.wpn6 = 0;
7843 253 tempitem.wpn7 = 0;
7844 253 tempitem.wpn8 = 0;
7845 253 tempitem.wpn9 = 0;
7846 253 tempitem.wpn10 = 0;
7847 253 break;
7848 }
7849 case itype_arrow:
7850 {
7851 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7852 250 tempitem.misc2 = 0;
7853 250 tempitem.misc3 = 0;
7854 250 tempitem.misc4 = 0;
7855 250 tempitem.misc5 = 0;
7856 250 tempitem.misc6 = 0;
7857 250 tempitem.misc7 = 0;
7858 250 tempitem.misc8 = 0;
7859 250 tempitem.misc9 = 0;
7860 250 tempitem.misc10 = 0;
7861 250 tempitem.wpn4 = 0;
7862 250 tempitem.wpn5 = 0;
7863 250 tempitem.wpn6 = 0;
7864 250 tempitem.wpn7 = 0;
7865 250 tempitem.wpn8 = 0;
7866 250 tempitem.wpn9 = 0;
7867 250 tempitem.wpn10 = 0;
7868 250 break;
7869 }
7870 case itype_candle:
7871 {
7872 206 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7873 206 tempitem.misc1 = 0;
7874 206 tempitem.misc2 = 0;
7875 206 tempitem.misc3 = 0;
7876 206 tempitem.misc4 = 0;
7877 206 tempitem.misc5 = 0;
7878 206 tempitem.misc6 = 0;
7879 206 tempitem.misc7 = 0;
7880 206 tempitem.misc8 = 0;
7881 206 tempitem.misc9 = 0;
7882 206 tempitem.misc10 = 0;
7883 206 tempitem.wpn4 = 0;
7884 206 tempitem.wpn5 = 0;
7885 206 tempitem.wpn6 = 0;
7886 206 tempitem.wpn7 = 0;
7887 206 tempitem.wpn8 = 0;
7888 206 tempitem.wpn9 = 0;
7889 206 tempitem.wpn10 = 0;
7890 206 break;
7891 }
7892 case itype_whistle:
7893 {
7894 130 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7895 130 tempitem.misc3 = 0;
7896 130 tempitem.misc4 = 0;
7897 130 tempitem.misc5 = 0;
7898 130 tempitem.misc6 = 0;
7899 130 tempitem.misc7 = 0;
7900 130 tempitem.misc8 = 0;
7901 130 tempitem.misc9 = 0;
7902 130 tempitem.misc10 = 0;
7903 130 tempitem.wpn2 = 0;
7904 130 tempitem.wpn3 = 0;
7905 130 tempitem.wpn4 = 0;
7906 130 tempitem.wpn5 = 0;
7907 130 tempitem.wpn6 = 0;
7908 130 tempitem.wpn7 = 0;
7909 130 tempitem.wpn8 = 0;
7910 130 tempitem.wpn9 = 0;
7911 130 tempitem.wpn10 = 0;
7912 130 break;
7913 }
7914 case itype_bait:
7915 {
7916 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7917 85 tempitem.misc2 = 0;
7918 85 tempitem.misc3 = 0;
7919 85 tempitem.misc4 = 0;
7920 85 tempitem.misc5 = 0;
7921 85 tempitem.misc6 = 0;
7922 85 tempitem.misc7 = 0;
7923 85 tempitem.misc8 = 0;
7924 85 tempitem.misc9 = 0;
7925 85 tempitem.misc10 = 0;
7926 85 tempitem.wpn2 = 0;
7927 85 tempitem.wpn3 = 0;
7928 85 tempitem.wpn4 = 0;
7929 85 tempitem.wpn5 = 0;
7930 85 tempitem.wpn6 = 0;
7931 85 tempitem.wpn7 = 0;
7932 85 tempitem.wpn8 = 0;
7933 85 tempitem.wpn9 = 0;
7934 85 tempitem.wpn10 = 0;
7935 85 break;
7936 }
7937 case itype_letter:
7938 {
7939 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7940 168 tempitem.misc1 = 0;
7941 168 tempitem.misc2 = 0;
7942 168 tempitem.misc3 = 0;
7943 168 tempitem.misc4 = 0;
7944 168 tempitem.misc5 = 0;
7945 168 tempitem.misc6 = 0;
7946 168 tempitem.misc7 = 0;
7947 168 tempitem.misc8 = 0;
7948 168 tempitem.misc9 = 0;
7949 168 tempitem.misc10 = 0;
7950 168 tempitem.wpn = 0;
7951 168 tempitem.wpn2 = 0;
7952 168 tempitem.wpn3 = 0;
7953 168 tempitem.wpn4 = 0;
7954 168 tempitem.wpn5 = 0;
7955 168 tempitem.wpn6 = 0;
7956 168 tempitem.wpn7 = 0;
7957 168 tempitem.wpn8 = 0;
7958 168 tempitem.wpn9 = 0;
7959 168 tempitem.wpn10 = 0;
7960 168 break;
7961 }
7962 case itype_potion:
7963 {
7964 167 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7965 167 tempitem.misc3 = 0;
7966 167 tempitem.misc4 = 0;
7967 167 tempitem.misc5 = 0;
7968 167 tempitem.misc6 = 0;
7969 167 tempitem.misc7 = 0;
7970 167 tempitem.misc8 = 0;
7971 167 tempitem.misc9 = 0;
7972 167 tempitem.misc10 = 0;
7973 167 tempitem.wpn = 0;
7974 167 tempitem.wpn2 = 0;
7975 167 tempitem.wpn3 = 0;
7976 167 tempitem.wpn4 = 0;
7977 167 tempitem.wpn5 = 0;
7978 167 tempitem.wpn6 = 0;
7979 167 tempitem.wpn7 = 0;
7980 167 tempitem.wpn8 = 0;
7981 167 tempitem.wpn9 = 0;
7982 167 tempitem.wpn10 = 0;
7983 167 break;
7984 }
7985 case itype_wand:
7986 {
7987 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7988 99 tempitem.misc1 = 0;
7989 99 tempitem.misc2 = 0;
7990 99 tempitem.misc3 = 0;
7991 99 tempitem.misc4 = 0;
7992 99 tempitem.misc5 = 0;
7993 99 tempitem.misc6 = 0;
7994 99 tempitem.misc7 = 0;
7995 99 tempitem.misc8 = 0;
7996 99 tempitem.misc9 = 0;
7997 99 tempitem.misc10 = 0;
7998 99 tempitem.wpn4 = 0;
7999 99 tempitem.wpn5 = 0;
8000 99 tempitem.wpn6 = 0;
8001 99 tempitem.wpn7 = 0;
8002 99 tempitem.wpn8 = 0;
8003 99 tempitem.wpn9 = 0;
8004 99 tempitem.wpn10 = 0;
8005 99 break;
8006 }
8007 case itype_ring:
8008 {
8009 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8010 278 tempitem.misc2 = 0;
8011 278 tempitem.misc3 = 0;
8012 278 tempitem.misc4 = 0;
8013 278 tempitem.misc5 = 0;
8014 278 tempitem.misc6 = 0;
8015 278 tempitem.misc7 = 0;
8016 278 tempitem.misc8 = 0;
8017 278 tempitem.misc9 = 0;
8018 278 tempitem.misc10 = 0;
8019 278 tempitem.wpn = 0;
8020 278 tempitem.wpn2 = 0;
8021 278 tempitem.wpn3 = 0;
8022 278 tempitem.wpn4 = 0;
8023 278 tempitem.wpn5 = 0;
8024 278 tempitem.wpn6 = 0;
8025 278 tempitem.wpn7 = 0;
8026 278 tempitem.wpn8 = 0;
8027 278 tempitem.wpn9 = 0;
8028 278 tempitem.wpn10 = 0;
8029 278 break;
8030 }
8031 case itype_wallet:
8032 {
8033 252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8034 252 tempitem.misc3 = 0;
8035 252 tempitem.misc4 = 0;
8036 252 tempitem.misc5 = 0;
8037 252 tempitem.misc6 = 0;
8038 252 tempitem.misc7 = 0;
8039 252 tempitem.misc8 = 0;
8040 252 tempitem.misc9 = 0;
8041 252 tempitem.misc10 = 0;
8042 252 tempitem.wpn = 0;
8043 252 tempitem.wpn2 = 0;
8044 252 tempitem.wpn3 = 0;
8045 252 tempitem.wpn4 = 0;
8046 252 tempitem.wpn5 = 0;
8047 252 tempitem.wpn6 = 0;
8048 252 tempitem.wpn7 = 0;
8049 252 tempitem.wpn8 = 0;
8050 252 tempitem.wpn9 = 0;
8051 252 tempitem.wpn10 = 0;
8052 252 break;
8053 }
8054 case itype_amulet:
8055 {
8056 167 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8057 167 tempitem.misc1 = 0;
8058 167 tempitem.misc2 = 0;
8059 167 tempitem.misc3 = 0;
8060 167 tempitem.misc4 = 0;
8061 167 tempitem.misc5 = 0;
8062 167 tempitem.misc6 = 0;
8063 167 tempitem.misc7 = 0;
8064 167 tempitem.misc8 = 0;
8065 167 tempitem.misc9 = 0;
8066 167 tempitem.misc10 = 0;
8067 167 tempitem.wpn = 0;
8068 167 tempitem.wpn2 = 0;
8069 167 tempitem.wpn3 = 0;
8070 167 tempitem.wpn4 = 0;
8071 167 tempitem.wpn5 = 0;
8072 167 tempitem.wpn6 = 0;
8073 167 tempitem.wpn7 = 0;
8074 167 tempitem.wpn8 = 0;
8075 167 tempitem.wpn9 = 0;
8076 167 tempitem.wpn10 = 0;
8077 167 break;
8078 }
8079 case itype_shield:
8080 {
8081 259 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8082 259 tempitem.misc3 = 0;
8083 259 tempitem.misc4 = 0;
8084 259 tempitem.misc5 = 0;
8085 259 tempitem.misc6 = 0;
8086 259 tempitem.misc7 = 0;
8087 259 tempitem.misc8 = 0;
8088 259 tempitem.misc9 = 0;
8089 259 tempitem.misc10 = 0;
8090 259 tempitem.wpn = 0;
8091 259 tempitem.wpn2 = 0;
8092 259 tempitem.wpn3 = 0;
8093 259 tempitem.wpn4 = 0;
8094 259 tempitem.wpn5 = 0;
8095 259 tempitem.wpn6 = 0;
8096 259 tempitem.wpn7 = 0;
8097 259 tempitem.wpn8 = 0;
8098 259 tempitem.wpn9 = 0;
8099 259 tempitem.wpn10 = 0;
8100 259 break;
8101 }
8102 case itype_bow:
8103 {
8104 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8105 168 tempitem.misc1 = 0;
8106 168 tempitem.misc2 = 0;
8107 168 tempitem.misc3 = 0;
8108 168 tempitem.misc4 = 0;
8109 168 tempitem.misc5 = 0;
8110 168 tempitem.misc6 = 0;
8111 168 tempitem.misc7 = 0;
8112 168 tempitem.misc8 = 0;
8113 168 tempitem.misc9 = 0;
8114 168 tempitem.misc10 = 0;
8115 168 tempitem.wpn = 0;
8116 168 tempitem.wpn2 = 0;
8117 168 tempitem.wpn3 = 0;
8118 168 tempitem.wpn4 = 0;
8119 168 tempitem.wpn5 = 0;
8120 168 tempitem.wpn6 = 0;
8121 168 tempitem.wpn7 = 0;
8122 168 tempitem.wpn8 = 0;
8123 168 tempitem.wpn9 = 0;
8124 168 tempitem.wpn10 = 0;
8125 168 break;
8126 }
8127 case itype_raft:
8128 {
8129 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8130 84 tempitem.misc1 = 0;
8131 84 tempitem.misc2 = 0;
8132 84 tempitem.misc3 = 0;
8133 84 tempitem.misc4 = 0;
8134 84 tempitem.misc5 = 0;
8135 84 tempitem.misc6 = 0;
8136 84 tempitem.misc7 = 0;
8137 84 tempitem.misc8 = 0;
8138 84 tempitem.misc9 = 0;
8139 84 tempitem.misc10 = 0;
8140 84 tempitem.wpn = 0;
8141 84 tempitem.wpn2 = 0;
8142 84 tempitem.wpn3 = 0;
8143 84 tempitem.wpn4 = 0;
8144 84 tempitem.wpn5 = 0;
8145 84 tempitem.wpn6 = 0;
8146 84 tempitem.wpn7 = 0;
8147 84 tempitem.wpn8 = 0;
8148 84 tempitem.wpn9 = 0;
8149 84 tempitem.wpn10 = 0;
8150 84 break;
8151 }
8152 case itype_ladder:
8153 {
8154 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8155 168 tempitem.misc1 = 0;
8156 168 tempitem.misc2 = 0;
8157 168 tempitem.misc3 = 0;
8158 168 tempitem.misc4 = 0;
8159 168 tempitem.misc5 = 0;
8160 168 tempitem.misc6 = 0;
8161 168 tempitem.misc7 = 0;
8162 168 tempitem.misc8 = 0;
8163 168 tempitem.misc9 = 0;
8164 168 tempitem.misc10 = 0;
8165 168 tempitem.wpn = 0;
8166 168 tempitem.wpn2 = 0;
8167 168 tempitem.wpn3 = 0;
8168 168 tempitem.wpn4 = 0;
8169 168 tempitem.wpn5 = 0;
8170 168 tempitem.wpn6 = 0;
8171 168 tempitem.wpn7 = 0;
8172 168 tempitem.wpn8 = 0;
8173 168 tempitem.wpn9 = 0;
8174 168 tempitem.wpn10 = 0;
8175 168 break;
8176 }
8177 case itype_book:
8178 {
8179 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8180 99 tempitem.misc1 = 0;
8181 99 tempitem.misc2 = 0;
8182 99 tempitem.misc3 = 0;
8183 99 tempitem.misc4 = 0;
8184 99 tempitem.misc5 = 0;
8185 99 tempitem.misc6 = 0;
8186 99 tempitem.misc7 = 0;
8187 99 tempitem.misc8 = 0;
8188 99 tempitem.misc9 = 0;
8189 99 tempitem.misc10 = 0;
8190 99 tempitem.wpn3 = 0;
8191 99 tempitem.wpn4 = 0;
8192 99 tempitem.wpn5 = 0;
8193 99 tempitem.wpn6 = 0;
8194 99 tempitem.wpn7 = 0;
8195 99 tempitem.wpn8 = 0;
8196 99 tempitem.wpn9 = 0;
8197 99 tempitem.wpn10 = 0;
8198 99 break;
8199 }
8200 case itype_magickey:
8201 {
8202 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8203 84 tempitem.misc1 = 0;
8204 84 tempitem.misc2 = 0;
8205 84 tempitem.misc3 = 0;
8206 84 tempitem.misc4 = 0;
8207 84 tempitem.misc5 = 0;
8208 84 tempitem.misc6 = 0;
8209 84 tempitem.misc7 = 0;
8210 84 tempitem.misc8 = 0;
8211 84 tempitem.misc9 = 0;
8212 84 tempitem.misc10 = 0;
8213 84 tempitem.wpn = 0;
8214 84 tempitem.wpn2 = 0;
8215 84 tempitem.wpn3 = 0;
8216 84 tempitem.wpn4 = 0;
8217 84 tempitem.wpn5 = 0;
8218 84 tempitem.wpn6 = 0;
8219 84 tempitem.wpn7 = 0;
8220 84 tempitem.wpn8 = 0;
8221 84 tempitem.wpn9 = 0;
8222 84 tempitem.wpn10 = 0;
8223 84 break;
8224 }
8225 case itype_bracelet:
8226 {
8227 255 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8228 255 tempitem.misc1 = 0;
8229 255 tempitem.misc2 = 0;
8230 255 tempitem.misc3 = 0;
8231 255 tempitem.misc4 = 0;
8232 255 tempitem.misc5 = 0;
8233 255 tempitem.misc6 = 0;
8234 255 tempitem.misc7 = 0;
8235 255 tempitem.misc8 = 0;
8236 255 tempitem.misc9 = 0;
8237 255 tempitem.misc10 = 0;
8238 255 tempitem.wpn = 0;
8239 255 tempitem.wpn2 = 0;
8240 255 tempitem.wpn3 = 0;
8241 255 tempitem.wpn4 = 0;
8242 255 tempitem.wpn5 = 0;
8243 255 tempitem.wpn6 = 0;
8244 255 tempitem.wpn7 = 0;
8245 255 tempitem.wpn8 = 0;
8246 255 tempitem.wpn9 = 0;
8247 255 tempitem.wpn10 = 0;
8248 255 break;
8249 }
8250 case itype_flippers:
8251 {
8252 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8253 85 tempitem.misc1 = 0;
8254 85 tempitem.misc2 = 0;
8255 85 tempitem.misc3 = 0;
8256 85 tempitem.misc4 = 0;
8257 85 tempitem.misc5 = 0;
8258 85 tempitem.misc6 = 0;
8259 85 tempitem.misc7 = 0;
8260 85 tempitem.misc8 = 0;
8261 85 tempitem.misc9 = 0;
8262 85 tempitem.misc10 = 0;
8263 85 tempitem.wpn = 0;
8264 85 tempitem.wpn2 = 0;
8265 85 tempitem.wpn3 = 0;
8266 85 tempitem.wpn4 = 0;
8267 85 tempitem.wpn5 = 0;
8268 85 tempitem.wpn6 = 0;
8269 85 tempitem.wpn7 = 0;
8270 85 tempitem.wpn8 = 0;
8271 85 tempitem.wpn9 = 0;
8272 85 tempitem.wpn10 = 0;
8273 85 break;
8274 }
8275 case itype_boots:
8276 {
8277 86 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8278 86 tempitem.misc1 = 0;
8279 86 tempitem.misc2 = 0;
8280 86 tempitem.misc3 = 0;
8281 86 tempitem.misc4 = 0;
8282 86 tempitem.misc5 = 0;
8283 86 tempitem.misc6 = 0;
8284 86 tempitem.misc7 = 0;
8285 86 tempitem.misc8 = 0;
8286 86 tempitem.misc9 = 0;
8287 86 tempitem.misc10 = 0;
8288 86 tempitem.wpn = 0;
8289 86 tempitem.wpn2 = 0;
8290 86 tempitem.wpn3 = 0;
8291 86 tempitem.wpn4 = 0;
8292 86 tempitem.wpn5 = 0;
8293 86 tempitem.wpn6 = 0;
8294 86 tempitem.wpn7 = 0;
8295 86 tempitem.wpn8 = 0;
8296 86 tempitem.wpn9 = 0;
8297 86 tempitem.wpn10 = 0;
8298 86 break;
8299 }
8300 case itype_hookshot:
8301 {
8302 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8303 168 tempitem.misc5 = 0;
8304 168 tempitem.misc6 = 0;
8305 168 tempitem.misc7 = 0;
8306 168 tempitem.misc8 = 0;
8307 168 tempitem.misc9 = 0;
8308 168 tempitem.misc10 = 0;
8309 168 tempitem.wpn5 = 0;
8310 168 tempitem.wpn6 = 0;
8311 168 tempitem.wpn7 = 0;
8312 168 tempitem.wpn8 = 0;
8313 168 tempitem.wpn9 = 0;
8314 168 tempitem.wpn10 = 0;
8315 168 break;
8316 }
8317 case itype_lens:
8318 {
8319 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8320 84 tempitem.misc2 = 0;
8321 84 tempitem.misc3 = 0;
8322 84 tempitem.misc4 = 0;
8323 84 tempitem.misc5 = 0;
8324 84 tempitem.misc6 = 0;
8325 84 tempitem.misc7 = 0;
8326 84 tempitem.misc8 = 0;
8327 84 tempitem.misc9 = 0;
8328 84 tempitem.misc10 = 0;
8329 84 tempitem.wpn = 0;
8330 84 tempitem.wpn2 = 0;
8331 84 tempitem.wpn3 = 0;
8332 84 tempitem.wpn4 = 0;
8333 84 tempitem.wpn5 = 0;
8334 84 tempitem.wpn6 = 0;
8335 84 tempitem.wpn7 = 0;
8336 84 tempitem.wpn8 = 0;
8337 84 tempitem.wpn9 = 0;
8338 84 tempitem.wpn10 = 0;
8339 84 break;
8340 }
8341 case itype_hammer:
8342 {
8343 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8344 85 tempitem.misc1 = 0;
8345 85 tempitem.misc2 = 0;
8346 85 tempitem.misc3 = 0;
8347 85 tempitem.misc4 = 0;
8348 85 tempitem.misc5 = 0;
8349 85 tempitem.misc6 = 0;
8350 85 tempitem.misc7 = 0;
8351 85 tempitem.misc8 = 0;
8352 85 tempitem.misc9 = 0;
8353 85 tempitem.misc10 = 0;
8354 85 tempitem.wpn3 = 0;
8355 85 tempitem.wpn4 = 0;
8356 85 tempitem.wpn5 = 0;
8357 85 tempitem.wpn6 = 0;
8358 85 tempitem.wpn7 = 0;
8359 85 tempitem.wpn8 = 0;
8360 85 tempitem.wpn9 = 0;
8361 85 tempitem.wpn10 = 0;
8362 85 break;
8363 }
8364 case itype_divinefire:
8365 {
8366 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8367 84 tempitem.misc3 = 0;
8368 84 tempitem.misc4 = 0;
8369 84 tempitem.misc5 = 0;
8370 84 tempitem.misc6 = 0;
8371 84 tempitem.misc7 = 0;
8372 84 tempitem.misc8 = 0;
8373 84 tempitem.misc9 = 0;
8374 84 tempitem.misc10 = 0;
8375 84 tempitem.wpn6 = 0;
8376 84 tempitem.wpn7 = 0;
8377 84 tempitem.wpn8 = 0;
8378 84 tempitem.wpn9 = 0;
8379 84 tempitem.wpn10 = 0;
8380 84 break;
8381 }
8382 case itype_divineescape:
8383 {
8384 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8385 84 tempitem.misc2 = 0;
8386 84 tempitem.misc3 = 0;
8387 84 tempitem.misc4 = 0;
8388 84 tempitem.misc5 = 0;
8389 84 tempitem.misc6 = 0;
8390 84 tempitem.misc7 = 0;
8391 84 tempitem.misc8 = 0;
8392 84 tempitem.misc9 = 0;
8393 84 tempitem.misc10 = 0;
8394 84 tempitem.wpn = 0;
8395 84 tempitem.wpn2 = 0;
8396 84 tempitem.wpn3 = 0;
8397 84 tempitem.wpn4 = 0;
8398 84 tempitem.wpn5 = 0;
8399 84 tempitem.wpn6 = 0;
8400 84 tempitem.wpn7 = 0;
8401 84 tempitem.wpn8 = 0;
8402 84 tempitem.wpn9 = 0;
8403 84 tempitem.wpn10 = 0;
8404 84 break;
8405 }
8406 case itype_divineprotection:
8407 {
8408 84 tempitem.flags &= ~ (ITEM_FLAG5);
8409 84 tempitem.misc2 = 0;
8410 84 tempitem.misc3 = 0;
8411 84 tempitem.misc4 = 0;
8412 84 tempitem.misc5 = 0;
8413 84 tempitem.misc6 = 0;
8414 84 tempitem.misc7 = 0;
8415 84 tempitem.misc8 = 0;
8416 84 tempitem.misc9 = 0;
8417 84 tempitem.misc10 = 0;
8418 84 break;
8419 }
8420 case itype_bomb:
8421 {
8422 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8423 99 tempitem.misc4 = 0;
8424 99 tempitem.misc5 = 0;
8425 99 tempitem.misc6 = 0;
8426 99 tempitem.misc7 = 0;
8427 99 tempitem.misc8 = 0;
8428 99 tempitem.misc9 = 0;
8429 99 tempitem.misc10 = 0;
8430 99 tempitem.wpn3 = 0;
8431 99 tempitem.wpn4 = 0;
8432 99 tempitem.wpn5 = 0;
8433 99 tempitem.wpn6 = 0;
8434 99 tempitem.wpn7 = 0;
8435 99 tempitem.wpn8 = 0;
8436 99 tempitem.wpn9 = 0;
8437 99 tempitem.wpn10 = 0;
8438 99 break;
8439 }
8440 case itype_sbomb:
8441 {
8442 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8443 84 tempitem.misc4 = 0;
8444 84 tempitem.misc5 = 0;
8445 84 tempitem.misc6 = 0;
8446 84 tempitem.misc7 = 0;
8447 84 tempitem.misc8 = 0;
8448 84 tempitem.misc9 = 0;
8449 84 tempitem.misc10 = 0;
8450 84 tempitem.wpn3 = 0;
8451 84 tempitem.wpn4 = 0;
8452 84 tempitem.wpn5 = 0;
8453 84 tempitem.wpn6 = 0;
8454 84 tempitem.wpn7 = 0;
8455 84 tempitem.wpn8 = 0;
8456 84 tempitem.wpn9 = 0;
8457 84 tempitem.wpn10 = 0;
8458 84 break;
8459 }
8460 case itype_clock:
8461 {
8462 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8463 85 tempitem.misc2 = 0;
8464 85 tempitem.misc3 = 0;
8465 85 tempitem.misc4 = 0;
8466 85 tempitem.misc5 = 0;
8467 85 tempitem.misc6 = 0;
8468 85 tempitem.misc7 = 0;
8469 85 tempitem.misc8 = 0;
8470 85 tempitem.misc9 = 0;
8471 85 tempitem.misc10 = 0;
8472 85 tempitem.wpn = 0;
8473 85 tempitem.wpn2 = 0;
8474 85 tempitem.wpn3 = 0;
8475 85 tempitem.wpn4 = 0;
8476 85 tempitem.wpn5 = 0;
8477 85 tempitem.wpn6 = 0;
8478 85 tempitem.wpn7 = 0;
8479 85 tempitem.wpn8 = 0;
8480 85 tempitem.wpn9 = 0;
8481 85 tempitem.wpn10 = 0;
8482 85 break;
8483 }
8484 case itype_key:
8485 {
8486 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8487 84 tempitem.misc1 = 0;
8488 84 tempitem.misc2 = 0;
8489 84 tempitem.misc3 = 0;
8490 84 tempitem.misc4 = 0;
8491 84 tempitem.misc5 = 0;
8492 84 tempitem.misc6 = 0;
8493 84 tempitem.misc7 = 0;
8494 84 tempitem.misc8 = 0;
8495 84 tempitem.misc9 = 0;
8496 84 tempitem.misc10 = 0;
8497 84 tempitem.wpn = 0;
8498 84 tempitem.wpn2 = 0;
8499 84 tempitem.wpn3 = 0;
8500 84 tempitem.wpn4 = 0;
8501 84 tempitem.wpn5 = 0;
8502 84 tempitem.wpn6 = 0;
8503 84 tempitem.wpn7 = 0;
8504 84 tempitem.wpn8 = 0;
8505 84 tempitem.wpn9 = 0;
8506 84 tempitem.wpn10 = 0;
8507 84 break;
8508 }
8509 case itype_magiccontainer:
8510 {
8511 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8512 85 tempitem.misc1 = 0;
8513 85 tempitem.misc2 = 0;
8514 85 tempitem.misc3 = 0;
8515 85 tempitem.misc4 = 0;
8516 85 tempitem.misc5 = 0;
8517 85 tempitem.misc6 = 0;
8518 85 tempitem.misc7 = 0;
8519 85 tempitem.misc8 = 0;
8520 85 tempitem.misc9 = 0;
8521 85 tempitem.misc10 = 0;
8522 85 tempitem.wpn = 0;
8523 85 tempitem.wpn2 = 0;
8524 85 tempitem.wpn3 = 0;
8525 85 tempitem.wpn4 = 0;
8526 85 tempitem.wpn5 = 0;
8527 85 tempitem.wpn6 = 0;
8528 85 tempitem.wpn7 = 0;
8529 85 tempitem.wpn8 = 0;
8530 85 tempitem.wpn9 = 0;
8531 85 tempitem.wpn10 = 0;
8532 85 break;
8533 }
8534 case itype_triforcepiece:
8535 {
8536 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8537 168 tempitem.misc3 = 0;
8538 168 tempitem.misc4 = 0;
8539 168 tempitem.misc5 = 0;
8540 168 tempitem.misc6 = 0;
8541 168 tempitem.misc7 = 0;
8542 168 tempitem.misc8 = 0;
8543 168 tempitem.misc9 = 0;
8544 168 tempitem.misc10 = 0;
8545 168 tempitem.wpn = 0;
8546 168 tempitem.wpn2 = 0;
8547 168 tempitem.wpn3 = 0;
8548 168 tempitem.wpn4 = 0;
8549 168 tempitem.wpn5 = 0;
8550 168 tempitem.wpn6 = 0;
8551 168 tempitem.wpn7 = 0;
8552 168 tempitem.wpn8 = 0;
8553 168 tempitem.wpn9 = 0;
8554 168 tempitem.wpn10 = 0;
8555 168 break;
8556 }
8557 case itype_map: case itype_compass: case itype_bosskey:
8558 {
8559 253 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8560 253 tempitem.misc1 = 0;
8561 253 tempitem.misc2 = 0;
8562 253 tempitem.misc3 = 0;
8563 253 tempitem.misc4 = 0;
8564 253 tempitem.misc5 = 0;
8565 253 tempitem.misc6 = 0;
8566 253 tempitem.misc7 = 0;
8567 253 tempitem.misc8 = 0;
8568 253 tempitem.misc9 = 0;
8569 253 tempitem.misc10 = 0;
8570 253 tempitem.wpn = 0;
8571 253 tempitem.wpn2 = 0;
8572 253 tempitem.wpn3 = 0;
8573 253 tempitem.wpn4 = 0;
8574 253 tempitem.wpn5 = 0;
8575 253 tempitem.wpn6 = 0;
8576 253 tempitem.wpn7 = 0;
8577 253 tempitem.wpn8 = 0;
8578 253 tempitem.wpn9 = 0;
8579 253 tempitem.wpn10 = 0;
8580 253 break;
8581 }
8582 case itype_quiver:
8583 {
8584 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8585 336 tempitem.misc3 = 0;
8586 336 tempitem.misc4 = 0;
8587 336 tempitem.misc5 = 0;
8588 336 tempitem.misc6 = 0;
8589 336 tempitem.misc7 = 0;
8590 336 tempitem.misc8 = 0;
8591 336 tempitem.misc9 = 0;
8592 336 tempitem.misc10 = 0;
8593 336 tempitem.wpn = 0;
8594 336 tempitem.wpn2 = 0;
8595 336 tempitem.wpn3 = 0;
8596 336 tempitem.wpn4 = 0;
8597 336 tempitem.wpn5 = 0;
8598 336 tempitem.wpn6 = 0;
8599 336 tempitem.wpn7 = 0;
8600 336 tempitem.wpn8 = 0;
8601 336 tempitem.wpn9 = 0;
8602 336 tempitem.wpn10 = 0;
8603 336 break;
8604 }
8605 case itype_lkey:
8606 {
8607 86 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8608 86 tempitem.misc1 = 0;
8609 86 tempitem.misc2 = 0;
8610 86 tempitem.misc3 = 0;
8611 86 tempitem.misc4 = 0;
8612 86 tempitem.misc5 = 0;
8613 86 tempitem.misc6 = 0;
8614 86 tempitem.misc7 = 0;
8615 86 tempitem.misc8 = 0;
8616 86 tempitem.misc9 = 0;
8617 86 tempitem.misc10 = 0;
8618 86 tempitem.wpn = 0;
8619 86 tempitem.wpn2 = 0;
8620 86 tempitem.wpn3 = 0;
8621 86 tempitem.wpn4 = 0;
8622 86 tempitem.wpn5 = 0;
8623 86 tempitem.wpn6 = 0;
8624 86 tempitem.wpn7 = 0;
8625 86 tempitem.wpn8 = 0;
8626 86 tempitem.wpn9 = 0;
8627 86 tempitem.wpn10 = 0;
8628 86 break;
8629 }
8630 case itype_cbyrna:
8631 {
8632 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8633 84 tempitem.misc4 = 0;
8634 84 tempitem.misc5 = 0;
8635 84 tempitem.misc6 = 0;
8636 84 tempitem.misc7 = 0;
8637 84 tempitem.misc8 = 0;
8638 84 tempitem.misc9 = 0;
8639 84 tempitem.misc10 = 0;
8640 84 tempitem.wpn6 = 0;
8641 84 tempitem.wpn7 = 0;
8642 84 tempitem.wpn8 = 0;
8643 84 tempitem.wpn9 = 0;
8644 84 tempitem.wpn10 = 0;
8645 84 break;
8646 }
8647 case itype_rupee: case itype_arrowammo:
8648 {
8649 1047 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8650 1047 tempitem.misc1 = 0;
8651 1047 tempitem.misc2 = 0;
8652 1047 tempitem.misc3 = 0;
8653 1047 tempitem.misc4 = 0;
8654 1047 tempitem.misc5 = 0;
8655 1047 tempitem.misc6 = 0;
8656 1047 tempitem.misc7 = 0;
8657 1047 tempitem.misc8 = 0;
8658 1047 tempitem.misc9 = 0;
8659 1047 tempitem.misc10 = 0;
8660 1047 tempitem.wpn = 0;
8661 1047 tempitem.wpn2 = 0;
8662 1047 tempitem.wpn3 = 0;
8663 1047 tempitem.wpn4 = 0;
8664 1047 tempitem.wpn5 = 0;
8665 1047 tempitem.wpn6 = 0;
8666 1047 tempitem.wpn7 = 0;
8667 1047 tempitem.wpn8 = 0;
8668 1047 tempitem.wpn9 = 0;
8669 1047 tempitem.wpn10 = 0;
8670 1047 break;
8671 }
8672 case itype_fairy:
8673 {
8674 152 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8675 152 tempitem.misc4 = 0;
8676 152 tempitem.misc5 = 0;
8677 152 tempitem.misc6 = 0;
8678 152 tempitem.misc7 = 0;
8679 152 tempitem.misc8 = 0;
8680 152 tempitem.misc9 = 0;
8681 152 tempitem.misc10 = 0;
8682 152 tempitem.wpn = 0;
8683 152 tempitem.wpn2 = 0;
8684 152 tempitem.wpn3 = 0;
8685 152 tempitem.wpn4 = 0;
8686 152 tempitem.wpn5 = 0;
8687 152 tempitem.wpn6 = 0;
8688 152 tempitem.wpn7 = 0;
8689 152 tempitem.wpn8 = 0;
8690 152 tempitem.wpn9 = 0;
8691 152 tempitem.wpn10 = 0;
8692 152 break;
8693 }
8694 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8695 {
8696 903 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8697 903 tempitem.misc1 = 0;
8698 903 tempitem.misc2 = 0;
8699 903 tempitem.misc3 = 0;
8700 903 tempitem.misc4 = 0;
8701 903 tempitem.misc5 = 0;
8702 903 tempitem.misc6 = 0;
8703 903 tempitem.misc7 = 0;
8704 903 tempitem.misc8 = 0;
8705 903 tempitem.misc9 = 0;
8706 903 tempitem.misc10 = 0;
8707 903 tempitem.wpn = 0;
8708 903 tempitem.wpn2 = 0;
8709 903 tempitem.wpn3 = 0;
8710 903 tempitem.wpn4 = 0;
8711 903 tempitem.wpn5 = 0;
8712 903 tempitem.wpn6 = 0;
8713 903 tempitem.wpn7 = 0;
8714 903 tempitem.wpn8 = 0;
8715 903 tempitem.wpn9 = 0;
8716 903 tempitem.wpn10 = 0;
8717 903 break;
8718 }
8719 case itype_bombbag:
8720 {
8721 336 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8722 336 tempitem.misc3 = 0;
8723 336 tempitem.misc4 = 0;
8724 336 tempitem.misc5 = 0;
8725 336 tempitem.misc6 = 0;
8726 336 tempitem.misc7 = 0;
8727 336 tempitem.misc8 = 0;
8728 336 tempitem.misc9 = 0;
8729 336 tempitem.misc10 = 0;
8730 336 tempitem.wpn = 0;
8731 336 tempitem.wpn2 = 0;
8732 336 tempitem.wpn3 = 0;
8733 336 tempitem.wpn4 = 0;
8734 336 tempitem.wpn5 = 0;
8735 336 tempitem.wpn6 = 0;
8736 336 tempitem.wpn7 = 0;
8737 336 tempitem.wpn8 = 0;
8738 336 tempitem.wpn9 = 0;
8739 336 tempitem.wpn10 = 0;
8740 336 break;
8741 }
8742 case itype_rocs:
8743 {
8744 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8745 84 tempitem.misc1 = 0;
8746 84 tempitem.misc2 = 0;
8747 84 tempitem.misc3 = 0;
8748 84 tempitem.misc4 = 0;
8749 84 tempitem.misc5 = 0;
8750 84 tempitem.misc6 = 0;
8751 84 tempitem.misc7 = 0;
8752 84 tempitem.misc8 = 0;
8753 84 tempitem.misc9 = 0;
8754 84 tempitem.misc10 = 0;
8755 84 tempitem.wpn = 0;
8756 84 tempitem.wpn2 = 0;
8757 84 tempitem.wpn3 = 0;
8758 84 tempitem.wpn4 = 0;
8759 84 tempitem.wpn5 = 0;
8760 84 tempitem.wpn6 = 0;
8761 84 tempitem.wpn7 = 0;
8762 84 tempitem.wpn8 = 0;
8763 84 tempitem.wpn9 = 0;
8764 84 tempitem.wpn10 = 0;
8765 84 break;
8766 }
8767 case itype_hoverboots:
8768 {
8769 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8770 84 tempitem.misc2 = 0;
8771 84 tempitem.misc3 = 0;
8772 84 tempitem.misc4 = 0;
8773 84 tempitem.misc5 = 0;
8774 84 tempitem.misc6 = 0;
8775 84 tempitem.misc7 = 0;
8776 84 tempitem.misc8 = 0;
8777 84 tempitem.misc9 = 0;
8778 84 tempitem.misc10 = 0;
8779 84 tempitem.wpn2 = 0;
8780 84 tempitem.wpn3 = 0;
8781 84 tempitem.wpn4 = 0;
8782 84 tempitem.wpn5 = 0;
8783 84 tempitem.wpn6 = 0;
8784 84 tempitem.wpn7 = 0;
8785 84 tempitem.wpn8 = 0;
8786 84 tempitem.wpn9 = 0;
8787 84 tempitem.wpn10 = 0;
8788 84 break;
8789 }
8790 case itype_spinscroll:
8791 {
8792 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8793 84 tempitem.misc2 = 0;
8794 84 tempitem.misc3 = 0;
8795 84 tempitem.misc4 = 0;
8796 84 tempitem.misc5 = 0;
8797 84 tempitem.misc6 = 0;
8798 84 tempitem.misc7 = 0;
8799 84 tempitem.misc8 = 0;
8800 84 tempitem.misc9 = 0;
8801 84 tempitem.misc10 = 0;
8802 84 tempitem.wpn = 0;
8803 84 tempitem.wpn2 = 0;
8804 84 tempitem.wpn3 = 0;
8805 84 tempitem.wpn4 = 0;
8806 84 tempitem.wpn5 = 0;
8807 84 tempitem.wpn6 = 0;
8808 84 tempitem.wpn7 = 0;
8809 84 tempitem.wpn8 = 0;
8810 84 tempitem.wpn9 = 0;
8811 84 tempitem.wpn10 = 0;
8812 84 break;
8813 }
8814 case itype_crossscroll:
8815 {
8816 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8817 84 tempitem.misc1 = 0;
8818 84 tempitem.misc2 = 0;
8819 84 tempitem.misc3 = 0;
8820 84 tempitem.misc4 = 0;
8821 84 tempitem.misc5 = 0;
8822 84 tempitem.misc6 = 0;
8823 84 tempitem.misc7 = 0;
8824 84 tempitem.misc8 = 0;
8825 84 tempitem.misc9 = 0;
8826 84 tempitem.misc10 = 0;
8827 84 tempitem.wpn = 0;
8828 84 tempitem.wpn2 = 0;
8829 84 tempitem.wpn3 = 0;
8830 84 tempitem.wpn4 = 0;
8831 84 tempitem.wpn5 = 0;
8832 84 tempitem.wpn6 = 0;
8833 84 tempitem.wpn7 = 0;
8834 84 tempitem.wpn8 = 0;
8835 84 tempitem.wpn9 = 0;
8836 84 tempitem.wpn10 = 0;
8837 84 break;
8838 }
8839 case itype_quakescroll:
8840 {
8841 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8842 84 tempitem.misc3 = 0;
8843 84 tempitem.misc4 = 0;
8844 84 tempitem.misc5 = 0;
8845 84 tempitem.misc6 = 0;
8846 84 tempitem.misc7 = 0;
8847 84 tempitem.misc8 = 0;
8848 84 tempitem.misc9 = 0;
8849 84 tempitem.misc10 = 0;
8850 84 tempitem.wpn = 0;
8851 84 tempitem.wpn2 = 0;
8852 84 tempitem.wpn3 = 0;
8853 84 tempitem.wpn4 = 0;
8854 84 tempitem.wpn5 = 0;
8855 84 tempitem.wpn6 = 0;
8856 84 tempitem.wpn7 = 0;
8857 84 tempitem.wpn8 = 0;
8858 84 tempitem.wpn9 = 0;
8859 84 tempitem.wpn10 = 0;
8860 84 break;
8861 }
8862 case itype_whispring:
8863 {
8864 169 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8865 169 tempitem.misc2 = 0;
8866 169 tempitem.misc3 = 0;
8867 169 tempitem.misc4 = 0;
8868 169 tempitem.misc5 = 0;
8869 169 tempitem.misc6 = 0;
8870 169 tempitem.misc7 = 0;
8871 169 tempitem.misc8 = 0;
8872 169 tempitem.misc9 = 0;
8873 169 tempitem.misc10 = 0;
8874 169 tempitem.wpn = 0;
8875 169 tempitem.wpn2 = 0;
8876 169 tempitem.wpn3 = 0;
8877 169 tempitem.wpn4 = 0;
8878 169 tempitem.wpn5 = 0;
8879 169 tempitem.wpn6 = 0;
8880 169 tempitem.wpn7 = 0;
8881 169 tempitem.wpn8 = 0;
8882 169 tempitem.wpn9 = 0;
8883 169 tempitem.wpn10 = 0;
8884 169 break;
8885 }
8886 case itype_chargering:
8887 {
8888 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8889 168 tempitem.misc3 = 0;
8890 168 tempitem.misc4 = 0;
8891 168 tempitem.misc5 = 0;
8892 168 tempitem.misc6 = 0;
8893 168 tempitem.misc7 = 0;
8894 168 tempitem.misc8 = 0;
8895 168 tempitem.misc9 = 0;
8896 168 tempitem.misc10 = 0;
8897 168 tempitem.wpn = 0;
8898 168 tempitem.wpn2 = 0;
8899 168 tempitem.wpn3 = 0;
8900 168 tempitem.wpn4 = 0;
8901 168 tempitem.wpn5 = 0;
8902 168 tempitem.wpn6 = 0;
8903 168 tempitem.wpn7 = 0;
8904 168 tempitem.wpn8 = 0;
8905 168 tempitem.wpn9 = 0;
8906 168 tempitem.wpn10 = 0;
8907 168 break;
8908 }
8909 case itype_perilscroll:
8910 {
8911 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8912 84 tempitem.misc2 = 0;
8913 84 tempitem.misc3 = 0;
8914 84 tempitem.misc4 = 0;
8915 84 tempitem.misc5 = 0;
8916 84 tempitem.misc6 = 0;
8917 84 tempitem.misc7 = 0;
8918 84 tempitem.misc8 = 0;
8919 84 tempitem.misc9 = 0;
8920 84 tempitem.misc10 = 0;
8921 84 tempitem.wpn = 0;
8922 84 tempitem.wpn2 = 0;
8923 84 tempitem.wpn3 = 0;
8924 84 tempitem.wpn4 = 0;
8925 84 tempitem.wpn5 = 0;
8926 84 tempitem.wpn6 = 0;
8927 84 tempitem.wpn7 = 0;
8928 84 tempitem.wpn8 = 0;
8929 84 tempitem.wpn9 = 0;
8930 84 tempitem.wpn10 = 0;
8931 84 break;
8932 }
8933 case itype_wealthmedal:
8934 {
8935 253 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8936 253 tempitem.misc2 = 0;
8937 253 tempitem.misc3 = 0;
8938 253 tempitem.misc4 = 0;
8939 253 tempitem.misc5 = 0;
8940 253 tempitem.misc6 = 0;
8941 253 tempitem.misc7 = 0;
8942 253 tempitem.misc8 = 0;
8943 253 tempitem.misc9 = 0;
8944 253 tempitem.misc10 = 0;
8945 253 tempitem.wpn = 0;
8946 253 tempitem.wpn2 = 0;
8947 253 tempitem.wpn3 = 0;
8948 253 tempitem.wpn4 = 0;
8949 253 tempitem.wpn5 = 0;
8950 253 tempitem.wpn6 = 0;
8951 253 tempitem.wpn7 = 0;
8952 253 tempitem.wpn8 = 0;
8953 253 tempitem.wpn9 = 0;
8954 253 tempitem.wpn10 = 0;
8955 253 break;
8956 }
8957 case itype_heartring:
8958 {
8959 254 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8960 254 tempitem.misc3 = 0;
8961 254 tempitem.misc4 = 0;
8962 254 tempitem.misc5 = 0;
8963 254 tempitem.misc6 = 0;
8964 254 tempitem.misc7 = 0;
8965 254 tempitem.misc8 = 0;
8966 254 tempitem.misc9 = 0;
8967 254 tempitem.misc10 = 0;
8968 254 tempitem.wpn = 0;
8969 254 tempitem.wpn2 = 0;
8970 254 tempitem.wpn3 = 0;
8971 254 tempitem.wpn4 = 0;
8972 254 tempitem.wpn5 = 0;
8973 254 tempitem.wpn6 = 0;
8974 254 tempitem.wpn7 = 0;
8975 254 tempitem.wpn8 = 0;
8976 254 tempitem.wpn9 = 0;
8977 254 tempitem.wpn10 = 0;
8978 254 break;
8979 }
8980 case itype_magicring:
8981 {
8982 340 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8983 340 tempitem.misc3 = 0;
8984 340 tempitem.misc4 = 0;
8985 340 tempitem.misc5 = 0;
8986 340 tempitem.misc6 = 0;
8987 340 tempitem.misc7 = 0;
8988 340 tempitem.misc8 = 0;
8989 340 tempitem.misc9 = 0;
8990 340 tempitem.misc10 = 0;
8991 340 tempitem.wpn = 0;
8992 340 tempitem.wpn2 = 0;
8993 340 tempitem.wpn3 = 0;
8994 340 tempitem.wpn4 = 0;
8995 340 tempitem.wpn5 = 0;
8996 340 tempitem.wpn6 = 0;
8997 340 tempitem.wpn7 = 0;
8998 340 tempitem.wpn8 = 0;
8999 340 tempitem.wpn9 = 0;
9000 340 tempitem.wpn10 = 0;
9001 340 break;
9002 }
9003 case itype_spinscroll2:
9004 {
9005 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9006 84 tempitem.misc2 = 0;
9007 84 tempitem.misc3 = 0;
9008 84 tempitem.misc4 = 0;
9009 84 tempitem.misc5 = 0;
9010 84 tempitem.misc6 = 0;
9011 84 tempitem.misc7 = 0;
9012 84 tempitem.misc8 = 0;
9013 84 tempitem.misc9 = 0;
9014 84 tempitem.misc10 = 0;
9015 84 tempitem.wpn = 0;
9016 84 tempitem.wpn2 = 0;
9017 84 tempitem.wpn3 = 0;
9018 84 tempitem.wpn4 = 0;
9019 84 tempitem.wpn5 = 0;
9020 84 tempitem.wpn6 = 0;
9021 84 tempitem.wpn7 = 0;
9022 84 tempitem.wpn8 = 0;
9023 84 tempitem.wpn9 = 0;
9024 84 tempitem.wpn10 = 0;
9025 84 break;
9026 }
9027 case itype_quakescroll2:
9028 {
9029 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9030 84 tempitem.misc3 = 0;
9031 84 tempitem.misc4 = 0;
9032 84 tempitem.misc5 = 0;
9033 84 tempitem.misc6 = 0;
9034 84 tempitem.misc7 = 0;
9035 84 tempitem.misc8 = 0;
9036 84 tempitem.misc9 = 0;
9037 84 tempitem.misc10 = 0;
9038 84 tempitem.wpn = 0;
9039 84 tempitem.wpn2 = 0;
9040 84 tempitem.wpn3 = 0;
9041 84 tempitem.wpn4 = 0;
9042 84 tempitem.wpn5 = 0;
9043 84 tempitem.wpn6 = 0;
9044 84 tempitem.wpn7 = 0;
9045 84 tempitem.wpn8 = 0;
9046 84 tempitem.wpn9 = 0;
9047 84 tempitem.wpn10 = 0;
9048 84 break;
9049 }
9050 case itype_agony:
9051 {
9052 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9053 84 tempitem.misc2 = 0;
9054 84 tempitem.misc3 = 0;
9055 84 tempitem.misc4 = 0;
9056 84 tempitem.misc5 = 0;
9057 84 tempitem.misc6 = 0;
9058 84 tempitem.misc7 = 0;
9059 84 tempitem.misc8 = 0;
9060 84 tempitem.misc9 = 0;
9061 84 tempitem.misc10 = 0;
9062 84 tempitem.wpn = 0;
9063 84 tempitem.wpn2 = 0;
9064 84 tempitem.wpn3 = 0;
9065 84 tempitem.wpn4 = 0;
9066 84 tempitem.wpn5 = 0;
9067 84 tempitem.wpn6 = 0;
9068 84 tempitem.wpn7 = 0;
9069 84 tempitem.wpn8 = 0;
9070 84 tempitem.wpn9 = 0;
9071 84 tempitem.wpn10 = 0;
9072 84 break;
9073 }
9074 case itype_stompboots:
9075 {
9076 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9077 84 tempitem.misc1 = 0;
9078 84 tempitem.misc2 = 0;
9079 84 tempitem.misc3 = 0;
9080 84 tempitem.misc4 = 0;
9081 84 tempitem.misc5 = 0;
9082 84 tempitem.misc6 = 0;
9083 84 tempitem.misc7 = 0;
9084 84 tempitem.misc8 = 0;
9085 84 tempitem.misc9 = 0;
9086 84 tempitem.misc10 = 0;
9087 84 tempitem.wpn = 0;
9088 84 tempitem.wpn2 = 0;
9089 84 tempitem.wpn3 = 0;
9090 84 tempitem.wpn4 = 0;
9091 84 tempitem.wpn5 = 0;
9092 84 tempitem.wpn6 = 0;
9093 84 tempitem.wpn7 = 0;
9094 84 tempitem.wpn8 = 0;
9095 84 tempitem.wpn9 = 0;
9096 84 tempitem.wpn10 = 0;
9097 84 break;
9098 }
9099 case itype_whimsicalring:
9100 {
9101 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9102 84 tempitem.misc2 = 0;
9103 84 tempitem.misc3 = 0;
9104 84 tempitem.misc4 = 0;
9105 84 tempitem.misc5 = 0;
9106 84 tempitem.misc6 = 0;
9107 84 tempitem.misc7 = 0;
9108 84 tempitem.misc8 = 0;
9109 84 tempitem.misc9 = 0;
9110 84 tempitem.misc10 = 0;
9111 84 tempitem.wpn = 0;
9112 84 tempitem.wpn2 = 0;
9113 84 tempitem.wpn3 = 0;
9114 84 tempitem.wpn4 = 0;
9115 84 tempitem.wpn5 = 0;
9116 84 tempitem.wpn6 = 0;
9117 84 tempitem.wpn7 = 0;
9118 84 tempitem.wpn8 = 0;
9119 84 tempitem.wpn9 = 0;
9120 84 tempitem.wpn10 = 0;
9121 84 break;
9122 }
9123 case itype_perilring:
9124 {
9125 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9126 85 tempitem.misc2 = 0;
9127 85 tempitem.misc3 = 0;
9128 85 tempitem.misc4 = 0;
9129 85 tempitem.misc5 = 0;
9130 85 tempitem.misc6 = 0;
9131 85 tempitem.misc7 = 0;
9132 85 tempitem.misc8 = 0;
9133 85 tempitem.misc9 = 0;
9134 85 tempitem.misc10 = 0;
9135 85 tempitem.wpn = 0;
9136 85 tempitem.wpn2 = 0;
9137 85 tempitem.wpn3 = 0;
9138 85 tempitem.wpn4 = 0;
9139 85 tempitem.wpn5 = 0;
9140 85 tempitem.wpn6 = 0;
9141 85 tempitem.wpn7 = 0;
9142 85 tempitem.wpn8 = 0;
9143 85 tempitem.wpn9 = 0;
9144 85 tempitem.wpn10 = 0;
9145 85 break;
9146 }
9147 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9148 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9149 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9150 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9151 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9152 {
9153 2368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9154 2368 tempitem.misc1 = 0;
9155 2368 tempitem.misc2 = 0;
9156 2368 tempitem.misc3 = 0;
9157 2368 tempitem.misc4 = 0;
9158 2368 tempitem.misc5 = 0;
9159 2368 tempitem.misc6 = 0;
9160 2368 tempitem.misc7 = 0;
9161 2368 tempitem.misc8 = 0;
9162 2368 tempitem.misc9 = 0;
9163 2368 tempitem.misc10 = 0;
9164 2368 tempitem.wpn = 0;
9165 2368 tempitem.wpn2 = 0;
9166 2368 tempitem.wpn3 = 0;
9167 2368 tempitem.wpn4 = 0;
9168 2368 tempitem.wpn5 = 0;
9169 2368 tempitem.wpn6 = 0;
9170 2368 tempitem.wpn7 = 0;
9171 2368 tempitem.wpn8 = 0;
9172 2368 tempitem.wpn9 = 0;
9173 2368 tempitem.wpn10 = 0;
9174 2368 break;
9175 }
9176 }
9177 21760 }
9178 //Port quest rules to items
9179
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version <= 31)
9180 {
9181
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_bomb)
9182 {
9183
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 10 times.
99 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9184 89 else tempitem.flags &= ~ ITEM_FLAG2;
9185 99 }
9186
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21577 times.
21661 else if(tempitem.family == itype_sbomb)
9187 {
9188
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 74 times.
84 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9189 74 else tempitem.flags &= ~ ITEM_FLAG2;
9190 84 }
9191
9192
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 21324 times.
21577 else if(tempitem.family == itype_brang)
9193 {
9194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9195 253 else tempitem.flags &= ~ ITEM_FLAG4;
9196 253 }
9197
2/2
✓ Branch 0 taken 21225 times.
✓ Branch 1 taken 99 times.
21324 else if(tempitem.family == itype_wand)
9198 {
9199
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 97 times.
99 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9200 97 else tempitem.flags &= ~ ITEM_FLAG3;
9201 99 }
9202 21760 }
9203
9204 //Port quest rules to items
9205
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version <= 37)
9206 {
9207
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21675 times.
21760 if(tempitem.family == itype_flippers)
9208 {
9209
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9210 85 else tempitem.flags &= ~ ITEM_FLAG1;
9211 85 }
9212
2/2
✓ Branch 0 taken 14827 times.
✓ Branch 1 taken 6848 times.
21675 else if(tempitem.family == itype_sword)
9213 {
9214
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9215 6779 else tempitem.flags &= ~ ITEM_FLAG5;
9216 6848 }
9217
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 14728 times.
14827 else if(tempitem.family == itype_wand)
9218 {
9219
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9220 96 else tempitem.flags &= ~ ITEM_FLAG5;
9221 99 }
9222
4/4
✓ Branch 0 taken 14629 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 14423 times.
14728 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9223 {
9224 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9225
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 72 times.
305 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9226 233 else tempitem.flags &= ~ ITEM_FLAG3;
9227 305 }
9228 21760 }
9229
9230
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 38)
9231 {
9232
4/4
✓ Branch 0 taken 21507 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 21339 times.
21760 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9233 {
9234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9235 421 else tempitem.flags &= ~ITEM_FLAG4;
9236
9237
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 410 times.
421 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9238 410 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9239 421 }
9240
2/2
✓ Branch 0 taken 21089 times.
✓ Branch 1 taken 250 times.
21339 else if(tempitem.family == itype_arrow)
9241 {
9242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9243 250 else tempitem.flags &= ~ITEM_FLAG4;
9244
9245
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 246 times.
250 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9246 246 else tempitem.flags |= ITEM_FLAG2;
9247 250 }
9248 21760 }
9249
9250
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 39)
9251 {
9252
6/6
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 21577 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 21371 times.
21760 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9253 {
9254
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 377 times.
389 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9255 377 else tempitem.flags &= ~ITEM_FLAG5;
9256 389 }
9257
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 21204 times.
21371 else if(tempitem.family == itype_potion)
9258 {
9259
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 157 times.
167 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9260 {
9261 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9262 10 }
9263 else
9264 {
9265 157 tempitem.flags |= ITEM_FLAG3;
9266
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 85 times.
157 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9267 72 else tempitem.flags &= ~ITEM_FLAG4;
9268 }
9269 167 }
9270
2/2
✓ Branch 0 taken 21036 times.
✓ Branch 1 taken 168 times.
21204 else if(tempitem.family == itype_triforcepiece)
9271 {
9272
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 152 times.
168 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9273 {
9274 16 tempitem.flags |= ITEM_FLAG3;
9275
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9276 10 else tempitem.flags &= ~ITEM_FLAG4;
9277 16 }
9278 else
9279 {
9280 152 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9281 }
9282 168 }
9283 21760 }
9284
9285
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 40)
9286 {
9287
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 21397 times.
21760 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9288 {
9289
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 316 times.
363 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9290 316 else tempitem.flags &= ~ITEM_FLAG1;
9291 363 }
9292
8/8
✓ Branch 0 taken 21191 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 14343 times.
✓ Branch 3 taken 6848 times.
✓ Branch 4 taken 14244 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 84 times.
✓ Branch 7 taken 14160 times.
21397 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9293 {
9294
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7156 times.
7237 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9295 7156 else tempitem.flags &= ~ITEM_FLAG8;
9296 7237 }
9297
6/6
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
✓ Branch 2 taken 14813 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 85 times.
✓ Branch 5 taken 14728 times.
21760 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9298 {
9299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7032 times.
7032 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9300 7032 else tempitem.flags &= ~ITEM_FLAG7;
9301 7032 }
9302
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 84 times.
14728 else if(tempitem.family == itype_cbyrna)
9303 {
9304 84 tempitem.flags |= ITEM_FLAG7;
9305 84 }
9306 21760 }
9307
9308
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 41 )
9309 {
9310
2/2
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
21760 if(tempitem.family == itype_sword)
9311 {
9312
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9313 6779 else tempitem.flags &= ~ITEM_FLAG9;
9314
9315
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9316 6779 else tempitem.flags &= ~ITEM_FLAG10;
9317 6848 }
9318 21760 }
9319
9320
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 42 )
9321 {
9322
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_wand)
9323 {
9324
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2 times.
99 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9325 97 else tempitem.flags &= ~ITEM_FLAG3;
9326
9327 99 tempitem.flags &= ~ITEM_FLAG6;
9328 99 }
9329
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21576 times.
21661 else if(tempitem.family == itype_hammer)
9330 {
9331 85 tempitem.flags &= ~ITEM_FLAG3;
9332 85 }
9333
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21492 times.
21576 else if(tempitem.family == itype_cbyrna)
9334 {
9335 84 tempitem.flags |= ITEM_FLAG3;
9336
9337 84 tempitem.flags &= ~ITEM_FLAG6;
9338 84 }
9339
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 6848 times.
21492 else if(tempitem.family == itype_sword)
9340 {
9341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6848 times.
6848 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9342 6848 else tempitem.flags &= ~ITEM_FLAG6;
9343 6848 }
9344 21760 }
9345
9346
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 43 )
9347 {
9348
2/2
✓ Branch 0 taken 21630 times.
✓ Branch 1 taken 130 times.
21760 if(tempitem.family == itype_whistle)
9349 {
9350
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9351 127 else tempitem.flags &= ~ITEM_FLAG3;
9352 130 }
9353 21760 }
9354
9355
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 45 )
9356 {
9357
2/2
✓ Branch 0 taken 21675 times.
✓ Branch 1 taken 85 times.
21760 if(tempitem.family == itype_flippers)
9358 {
9359 85 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9360 85 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9361 85 }
9362 21760 }
9363
9364
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 46 )
9365 {
9366
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if(tempitem.family == itype_raft)
9367 {
9368 84 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9369 84 }
9370 21760 }
9371
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if ( s_version < 34 ) //! set the default counter for older quests.
9372 {
9373
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 21686 times.
21760 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9374 {
9375 74 tempitem.cost_counter[0] = 1;
9376 74 }
9377 else
9378 {
9379
2/2
✓ Branch 0 taken 18870 times.
✓ Branch 1 taken 2816 times.
21686 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9380 2816 tempitem.cost_counter[0] = 4;
9381 else
9382 {
9383 18870 tempitem.cost_amount[0] = 0;
9384 18870 tempitem.cost_counter[0] = -1;
9385 }
9386 }
9387 21760 }
9388
9389
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if ( s_version < 35 ) //new Lens of Truth flags
9390 {
9391
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if ( tempitem.family == itype_lens )
9392 {
9393
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 3 times.
84 if ( get_bit(quest_rules,qr_RAFTLENS) )
9394 {
9395 3 tempitem.flags |= ITEM_FLAG4;
9396 3 }
9397
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 45 times.
84 if ( get_bit(quest_rules,qr_LENSHINTS) )
9398 {
9399 45 tempitem.flags |= ITEM_FLAG1;
9400 45 }
9401
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4 times.
84 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9402 {
9403 4 tempitem.flags |= ITEM_FLAG5;
9404 4 }
9405 84 }
9406 21760 }
9407
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9408 {
9409
2/2
✓ Branch 0 taken 174080 times.
✓ Branch 1 taken 21760 times.
195840 for ( int32_t q = 0; q < 8; q++ )
9410 {
9411 174080 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9412 174080 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9413 174080 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9414 174080 tempitem.sprite_initiald[q] = 0;
9415 174080 }
9416
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 21760 times.
65280 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9417 21760 tempitem.sprite_script = 0;
9418 21760 }
9419
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9420 {
9421 21760 tempitem.pickupflag = 0;
9422 21760 }
9423
9424
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 51 )
9425 {
9426
2/2
✓ Branch 0 taken 21554 times.
✓ Branch 1 taken 206 times.
21760 if( tempitem.family == itype_candle )
9427 {
9428 206 tempitem.misc4 = 50; //Step speed
9429 206 }
9430 21760 }
9431
9432
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if( s_version < 52 )
9433 {
9434
2/2
✓ Branch 0 taken 21501 times.
✓ Branch 1 taken 259 times.
21760 if( tempitem.family == itype_shield )
9435 259 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9436 21760 }
9437
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21760 times.
27648 if(s_version < 53)
9438 {
9439
4/4
✓ Branch 0 taken 21327 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 84 times.
21760 switch(tempitem.family)
9440 {
9441 case itype_arrow:
9442 250 tempitem.cost_counter[1] = crARROWS;
9443 250 tempitem.cost_amount[1] = 1;
9444 250 break;
9445 case itype_bomb:
9446 99 tempitem.cost_counter[1] = crBOMBS;
9447 99 tempitem.cost_amount[1] = 1;
9448 99 break;
9449 case itype_sbomb:
9450 84 tempitem.cost_counter[1] = crSBOMBS;
9451 84 tempitem.cost_amount[1] = 1;
9452 84 break;
9453 default:
9454 21327 tempitem.cost_counter[1] = crNONE;
9455 21327 tempitem.cost_amount[1] = 0;
9456 21327 }
9457 21760 tempitem.magiccosttimer[1] = 0;
9458 21760 }
9459
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if( s_version < 54 )
9460 {
9461
2/2
✓ Branch 0 taken 25244 times.
✓ Branch 1 taken 100 times.
25344 if( tempitem.family == itype_flippers )
9462 100 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9463 25344 }
9464
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if(s_version < 55)
9465 {
9466
3/3
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 24952 times.
25344 switch(tempitem.family)
9467 {
9468 case itype_spinscroll:
9469 case itype_quakescroll:
9470 196 tempitem.usesound2 = WAV_ZN1CHARGE;
9471 196 break;
9472 case itype_spinscroll2:
9473 case itype_quakescroll2:
9474 196 tempitem.usesound2 = WAV_ZN1CHARGE2;
9475 196 break;
9476 }
9477 25344 }
9478
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if(s_version < 56)
9479 {
9480
4/4
✓ Branch 0 taken 24897 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 113 times.
25344 switch(tempitem.family)
9481 {
9482 case itype_divinefire:
9483
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 14 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9484
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9485 98 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9486 98 break;
9487 case itype_candle:
9488
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 121 times.
236 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9489 236 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9490 236 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9491 236 break;
9492 case itype_book:
9493 113 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9494 113 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9495 113 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9496 113 break;
9497 }
9498 25344 }
9499
9500
2/2
✓ Branch 0 taken 26442 times.
✓ Branch 1 taken 1206 times.
27648 if(tempitem.fam_type==0) // Always do this
9501 1206 tempitem.fam_type=1;
9502
9503 27648 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9504 27648 }
9505 108 }
9506
9507 108 return 0;
9508 108 }
9509
9510 static bool did_init_def_items = false;
9511 56055 void init_def_items()
9512 {
9513
2/2
✓ Branch 0 taken 56022 times.
✓ Branch 1 taken 33 times.
56055 if(did_init_def_items) return;
9514 33 did_init_def_items = true;
9515 33 default_items[3].cost_counter[1] = crBOMBS;
9516 33 default_items[13].cost_counter[1] = crARROWS;
9517 33 default_items[14].cost_counter[1] = crARROWS;
9518 33 default_items[48].cost_counter[1] = crSBOMBS;
9519 33 default_items[57].cost_counter[1] = crARROWS;
9520 56055 }
9521 56055 void reset_itembuf(itemdata *item, int32_t id)
9522 {
9523 56055 init_def_items();
9524
2/2
✓ Branch 0 taken 24295 times.
✓ Branch 1 taken 31760 times.
56055 if(id<iLast)
9525 {
9526 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9527 31760 word tile = item->tile;
9528 31760 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9529 31760 int32_t ltm = item->ltm;
9530
9531 31760 memcpy(item,&default_items[id],sizeof(itemdata));
9532 31760 item->tile = tile;
9533 31760 item->misc_flags = miscs;
9534 31760 item->csets = cset;
9535 31760 item->frames = frames;
9536 31760 item->speed = speed;
9537 31760 item->delay = delay;
9538 31760 item->ltm = ltm;
9539 31760 }
9540 56055 }
9541
9542 10752 void reset_itemname(int32_t id)
9543 {
9544 10752 sprintf(item_string[id],"zz%03d",id);
9545
9546
2/2
✓ Branch 0 taken 4746 times.
✓ Branch 1 taken 6006 times.
10752 if(id < iLast)
9547 6006 strcpy(item_string[id],old_item_string[id]);
9548 10752 }
9549
9550 108 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9551 {
9552 108 word weapons_to_read=MAXWPNS;
9553 int32_t dummy;
9554 byte padding;
9555 wpndata tempweapon;
9556 108 word s_version=0, s_cversion=0;
9557
9558
9559
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x186)
9560 {
9561 weapons_to_read=64;
9562 }
9563
9564
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x185)
9565 {
9566 weapons_to_read=32;
9567 }
9568
9569
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
9570 {
9571 104 weapons_to_read=0;
9572
9573 //section version info
9574
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
9575 {
9576 return qe_invalid;
9577 }
9578
9579 104 FFCore.quest_format[vWeaponSprites] = s_version;
9580
9581 //al_trace("Weapons version %d\n", s_version);
9582
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
9583 {
9584 return qe_invalid;
9585 }
9586
9587 //section size
9588
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
9589 {
9590 return qe_invalid;
9591 }
9592
9593 //finally... section data
9594
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&weapons_to_read,f,true))
9595 {
9596 return qe_invalid;
9597 }
9598 104 }
9599
9600
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version>2)
9601 {
9602
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<weapons_to_read; i++)
9603 {
9604 char tempname[64];
9605
9606
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!pfread(tempname, 64, f, keepdata))
9607 {
9608 return qe_invalid;
9609 }
9610
9611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(keepdata)
9612 {
9613 25344 strcpy(weapon_string[i], tempname);
9614 25344 }
9615 25344 }
9616
9617
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version<4)
9618 {
9619 if(keepdata)
9620 {
9621 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9622 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9623 }
9624 }
9625
9626
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version<5)
9627 {
9628 if(keepdata)
9629 {
9630 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9631 }
9632 }
9633
9634 /*
9635 if (s_version<6)
9636 {
9637 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9638 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9639 }
9640 */
9641 99 }
9642 else
9643 {
9644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9645
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9646 2313 reset_weaponname(i);
9647 }
9648
9649
2/2
✓ Branch 0 taken 26708 times.
✓ Branch 1 taken 108 times.
26816 for(int32_t i=0; i<weapons_to_read; i++)
9650 {
9651 26708 word oldtile = 0;
9652
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 21332 times.
26708 if (s_version < 8)
9653 {
9654
1/2
✓ Branch 0 taken 21332 times.
✗ Branch 1 not taken.
21332 if (!p_igetw(&oldtile, f, true))
9655 return qe_invalid;
9656 21332 }
9657
9658
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.misc,f,true))
9659 {
9660 return qe_invalid;
9661 }
9662
9663
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.csets,f,true))
9664 {
9665 return qe_invalid;
9666 }
9667
9668
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.frames,f,true))
9669 {
9670 return qe_invalid;
9671 }
9672
9673
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.speed,f,true))
9674 {
9675 return qe_invalid;
9676 }
9677
9678
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.type,f,true))
9679 {
9680 return qe_invalid;
9681 }
9682
9683
2/2
✓ Branch 0 taken 20820 times.
✓ Branch 1 taken 5888 times.
26708 if ( s_version >= 7 )
9684 {
9685
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempweapon.script,f,true))
9686 {
9687 return qe_invalid;
9688 }
9689
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempweapon.tile,f,true))
9690 {
9691 return qe_invalid;
9692 }
9693 5888 }
9694
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20820 times.
26708 if ( s_version < 7 )
9695 {
9696 20820 tempweapon.tile = oldtile;
9697 20820 }
9698
9699
2/2
✓ Branch 0 taken 25684 times.
✓ Branch 1 taken 1024 times.
26708 if(Header->zelda_version < 0x193)
9700 {
9701
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9702 {
9703 return qe_invalid;
9704 }
9705 1024 }
9706
9707
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 1364 times.
26708 if(s_version < 6)
9708 {
9709
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9710 {
9711 4 tempweapon.misc |= WF_BEHIND;
9712 4 }
9713 else
9714 1360 tempweapon.misc &= ~WF_BEHIND;
9715 1364 }
9716
9717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26708 times.
26708 if(keepdata==true)
9718 {
9719 26708 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9720 26708 }
9721 26708 }
9722
9723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
9724 {
9725
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<2)
9726 {
9727 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9728 9 }
9729
9730
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<5)
9731 {
9732 9 wpnsbuf[iwQuarterHearts].tile=1;
9733 9 wpnsbuf[iwQuarterHearts].csets=1;
9734 9 }
9735
9736
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x176)
9737 {
9738 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9739 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9740 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9741 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9742 }
9743
9744
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
9745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9746 {
9747 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9748 4 }
9749
9750
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if((Header->zelda_version < 0x210))
9751 {
9752 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9753 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9754 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9755 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9756 4 }
9757 108 }
9758
9759 108 return 0;
9760 108 }
9761
9762 108 void init_guys(int32_t guyversion)
9763 {
9764
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<MAXGUYS; i++)
9765 {
9766 55296 guysbuf[i] = default_guys[0];
9767 55296 }
9768
9769
2/2
✓ Branch 0 taken 19116 times.
✓ Branch 1 taken 108 times.
19224 for(int32_t i=0; i<OLDMAXGUYS; i++)
9770 {
9771 19116 guysbuf[i] = default_guys[i];
9772
2/2
✓ Branch 0 taken 18900 times.
✓ Branch 1 taken 216 times.
19116 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9773 19116 guysbuf[i].spr_death = iwDeath;
9774 19116 guysbuf[i].spr_spawn = iwSpawn;
9775 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9776
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 17523 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
19116 if(guyversion<=3 && i==ePATRABS)
9777 {
9778 9 guysbuf[i].bosspal=spDIG;
9779 9 guysbuf[i].cset=14;
9780 9 guysbuf[i].misc9=14;
9781 9 }
9782
9783
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 1593 times.
19116 if(guyversion<=3)
9784 {
9785 // Rope/Ghini Flash rules
9786
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9787 {
9788
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9789 {
9790 5 guysbuf[i].flags2 &= ~guy_flashing;
9791 5 }
9792 885 }
9793
9794
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9795 {
9796
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9797 {
9798 18 guysbuf[i].flags2 &= ~guy_flashing;
9799 18 }
9800 531 }
9801
9802
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9803 {
9804
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9805 {
9806 3 guysbuf[i].flags2 |= guy_blinking;
9807 3 }
9808
9809
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9810 {
9811 guysbuf[i].flags2 |= guy_transparent;
9812 }
9813 9 }
9814 1593 }
9815
9816 // Darknut fix
9817
10/10
✓ Branch 0 taken 19008 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 18900 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 18792 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 18684 times.
✓ Branch 7 taken 108 times.
✓ Branch 8 taken 108 times.
✓ Branch 9 taken 18576 times.
19116 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9818 {
9819
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 205 times.
540 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9820 {
9821 335 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9822 335 guysbuf[i].s_width=guysbuf[i].e_width;
9823 335 guysbuf[i].s_height=guysbuf[i].e_height;
9824 335 }
9825 205 else guysbuf[i].s_tile=860;
9826
9827
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 35 times.
540 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9828 {
9829 35 guysbuf[i].flags |= guy_bkshield;
9830 35 }
9831 540 }
9832
9833
4/4
✓ Branch 0 taken 19008 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 19108 times.
✓ Branch 3 taken 8 times.
19116 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9834 {
9835 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9836 8 }
9837 19116 }
9838 108 }
9839
9840 2304 void reset_weaponname(int32_t i)
9841 {
9842
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9843 {
9844 792 strcpy(weapon_string[i],old_weapon_string[i]);
9845 792 }
9846 else
9847 1512 sprintf(weapon_string[i],"zz%03d",i);
9848 2304 }
9849
9850 108 void init_item_drop_sets()
9851 {
9852
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9853 {
9854 // item_drop_sets[i] = default_item_drop_sets[0];
9855 27648 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9856 27648 }
9857
9858
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 108 times.
1512 for(int32_t i=0; i<isMAX; i++)
9859 {
9860 1404 item_drop_sets[i] = default_item_drop_sets[i];
9861
9862 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9863
2/2
✓ Branch 0 taken 14040 times.
✓ Branch 1 taken 1404 times.
15444 for(int32_t j=0; j<10; ++j)
9864 {
9865 14040 int32_t it = item_drop_sets[i].item[j];
9866
9867
3/4
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 4196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 636 times.
14040 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9868
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 9208 times.
9844 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9869 {
9870 636 item_drop_sets[i].chance[j+1]=0;
9871 636 }
9872
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 12972 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
13404 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9873 {
9874 item_drop_sets[i].chance[j+1]=0;
9875 }
9876
9877 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9878
2/2
✓ Branch 0 taken 14032 times.
✓ Branch 1 taken 8 times.
14040 if(itemsbuf[it].family == itype_misc)
9879 {
9880 // If a non-gameplay item was selected, then item drop was aborted.
9881 // Reflect this by increasing the 'Nothing' chance accordingly.
9882 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9883 8 item_drop_sets[i].chance[j+1]=0;
9884 8 }
9885 14040 }
9886 1404 }
9887 108 }
9888
9889 104 void init_favorites()
9890 {
9891
2/2
✓ Branch 0 taken 31200 times.
✓ Branch 1 taken 104 times.
31304 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9892 {
9893 31200 favorite_combos[i]=-1;
9894 31200 }
9895
9896
2/2
✓ Branch 0 taken 31200 times.
✓ Branch 1 taken 104 times.
31304 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9897 {
9898 31200 favorite_comboaliases[i]=-1;
9899 31200 }
9900 104 }
9901
9902 const char *ctype_name[cMAX]=
9903 {
9904 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9905 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9906 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9907 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9908 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9909 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9910 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9911 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9912 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9913 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9914 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9915 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9916 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9917 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9918 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9919 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9920 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9921 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9922 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9923 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9924 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9925 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9926 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9927 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9928 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9929 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9930 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9931 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9932
9933 };
9934
9935 195 int32_t init_combo_classes()
9936 {
9937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9938
2/2
✓ Branch 0 taken 35295 times.
✓ Branch 1 taken 195 times.
35490 for(int32_t i=0; i<cMAX; i++)
9939 {
9940 35295 combo_class_buf[i] = default_combo_classes[i];
9941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35295 times.
35295 if ( char const* nm = zi->getComboTypeName(i) )
9942 {
9943 35295 size_t len = strlen(nm);
9944
2/2
✓ Branch 0 taken 2258880 times.
✓ Branch 1 taken 35295 times.
2294175 for ( size_t q = 0; q < 64; q++ )
9945 {
9946
2/2
✓ Branch 0 taken 521625 times.
✓ Branch 1 taken 1737255 times.
2258880 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9947 2258880 }
9948 35295 }
9949 35295 }
9950
9951 195 return 0;
9952 }
9953
9954 89 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9955 {
9956
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 assert(v_herosprites < 6);
9957 //these are here to bypass compiler warnings about unused arguments
9958 89 cv_herosprites=cv_herosprites;
9959
9960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(keepdata)
9961 {
9962 89 zinit.hero_swim_speed=67; //default
9963 89 setupherotiles(zinit.heroAnimationStyle);
9964 89 setupherodefenses();
9965 89 setupherooffsets();
9966 89 }
9967
9968
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 76 times.
89 if(v_herosprites>=0)
9969 {
9970 word tile, tile2;
9971 byte flip, extend, dummy_byte;
9972
9973
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
9974 {
9975
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
9976 {
9977 return qe_invalid;
9978 }
9979
9980
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
9981 {
9982 return qe_invalid;
9983 }
9984
9985
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
9986 {
9987 return qe_invalid;
9988 }
9989
9990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
9991 {
9992 304 walkspr[i][spr_tile]=(int32_t)tile;
9993 304 walkspr[i][spr_flip]=(int32_t)flip;
9994 304 walkspr[i][spr_extend]=(int32_t)extend;
9995 304 }
9996 304 }
9997
9998
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
9999 {
10000
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10001 {
10002 return qe_invalid;
10003 }
10004
10005
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10006 {
10007 return qe_invalid;
10008 }
10009
10010
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10011 {
10012 return qe_invalid;
10013 }
10014
10015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10016 {
10017 304 stabspr[i][spr_tile]=(int32_t)tile;
10018 304 stabspr[i][spr_flip]=(int32_t)flip;
10019 304 stabspr[i][spr_extend]=(int32_t)extend;
10020 304 }
10021 304 }
10022
10023
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10024 {
10025
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10026 {
10027 return qe_invalid;
10028 }
10029
10030
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10031 {
10032 return qe_invalid;
10033 }
10034
10035
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10041 {
10042 304 slashspr[i][spr_tile]=(int32_t)tile;
10043 304 slashspr[i][spr_flip]=(int32_t)flip;
10044 304 slashspr[i][spr_extend]=(int32_t)extend;
10045 304 }
10046 304 }
10047
10048
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10049 {
10050
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10051 {
10052 return qe_invalid;
10053 }
10054
10055
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10056 {
10057 return qe_invalid;
10058 }
10059
10060
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10061 {
10062 return qe_invalid;
10063 }
10064
10065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10066 {
10067 304 floatspr[i][spr_tile]=(int32_t)tile;
10068 304 floatspr[i][spr_flip]=(int32_t)flip;
10069 304 floatspr[i][spr_extend]=(int32_t)extend;
10070 304 }
10071 304 }
10072
10073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>1)
10074 {
10075
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10076 {
10077
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10078 {
10079 return qe_invalid;
10080 }
10081
10082
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10083 {
10084 return qe_invalid;
10085 }
10086
10087
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10088 {
10089 return qe_invalid;
10090 }
10091
10092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10093 {
10094 304 swimspr[i][spr_tile]=(int32_t)tile;
10095 304 swimspr[i][spr_flip]=(int32_t)flip;
10096 304 swimspr[i][spr_extend]=(int32_t)extend;
10097 304 }
10098 304 }
10099 76 }
10100
10101
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10102 {
10103
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10109 {
10110 return qe_invalid;
10111 }
10112
10113
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10114 {
10115 return qe_invalid;
10116 }
10117
10118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10119 {
10120 304 divespr[i][spr_tile]=(int32_t)tile;
10121 304 divespr[i][spr_flip]=(int32_t)flip;
10122 304 divespr[i][spr_extend]=(int32_t)extend;
10123 304 }
10124 304 }
10125
10126
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10127 {
10128
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10139 {
10140 return qe_invalid;
10141 }
10142
10143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10144 {
10145 304 poundspr[i][spr_tile]=(int32_t)tile;
10146 304 poundspr[i][spr_flip]=(int32_t)flip;
10147 304 poundspr[i][spr_extend]=(int32_t)extend;
10148 304 }
10149 304 }
10150
10151
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&tile,f,keepdata))
10152 {
10153 return qe_invalid;
10154 }
10155
10156 76 flip=0;
10157
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>0)
10159 {
10160
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&flip,f,keepdata))
10161 {
10162 return qe_invalid;
10163 }
10164 76 }
10165
10166
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&extend,f,keepdata))
10167 {
10168 return qe_invalid;
10169 }
10170
10171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10172 {
10173 76 castingspr[spr_tile]=(int32_t)tile;
10174 76 castingspr[spr_flip]=(int32_t)flip;
10175 76 castingspr[spr_extend]=(int32_t)extend;
10176 76 }
10177
10178
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(v_herosprites>0)
10179 {
10180 76 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10181
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 76 times.
228 for(int32_t i=0; i<2; i++)
10182 {
10183
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 152 times.
456 for(int32_t j=0; j<num_holdsprs; j++)
10184 {
10185
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10186 {
10187 return qe_invalid;
10188 }
10189
10190
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10191 {
10192 return qe_invalid;
10193 }
10194
10195
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10196 {
10197 return qe_invalid;
10198 }
10199
10200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10201 {
10202 304 holdspr[i][j][spr_tile]=(int32_t)tile;
10203 304 holdspr[i][j][spr_flip]=(int32_t)flip;
10204 304 holdspr[i][j][spr_extend]=(int32_t)extend;
10205 304 }
10206 304 }
10207 152 }
10208 76 }
10209 else
10210 {
10211 for(int32_t i=0; i<2; i++)
10212 {
10213 if(!p_igetw(&tile,f,keepdata))
10214 {
10215 return qe_invalid;
10216 }
10217
10218 if(!p_igetw(&tile2,f,keepdata))
10219 {
10220 return qe_invalid;
10221 }
10222
10223 if(!p_getc(&extend,f,keepdata))
10224 {
10225 return qe_invalid;
10226 }
10227
10228 if(keepdata)
10229 {
10230 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10231 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10232 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10233 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10234 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10235 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10236 }
10237 }
10238 }
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>2)
10241 {
10242
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10243 {
10244
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10245 {
10246 return qe_invalid;
10247 }
10248
10249
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10250 {
10251 return qe_invalid;
10252 }
10253
10254
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10260 {
10261 304 jumpspr[i][spr_tile]=(int32_t)tile;
10262 304 jumpspr[i][spr_flip]=(int32_t)flip;
10263 304 jumpspr[i][spr_extend]=(int32_t)extend;
10264 304 }
10265 304 }
10266 76 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>3)
10269 {
10270
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10271 {
10272
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10273 {
10274 return qe_invalid;
10275 }
10276
10277
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10288 {
10289 304 chargespr[i][spr_tile]=(int32_t)tile;
10290 304 chargespr[i][spr_flip]=(int32_t)flip;
10291 304 chargespr[i][spr_extend]=(int32_t)extend;
10292 304 }
10293 304 }
10294 76 }
10295
10296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>4)
10297 {
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!p_getc(&dummy_byte,f,keepdata))
10299 {
10300 return qe_invalid;
10301 }
10302
10303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10304 {
10305 76 zinit.hero_swim_speed=(byte)dummy_byte;
10306 76 }
10307 76 }
10308
10309
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(keepdata)
10310 {
10311 76 memset(frozenspr, 0, sizeof(frozenspr));
10312 76 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10313 76 memset(onfirespr, 0, sizeof(onfirespr));
10314 76 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10315 76 memset(diggingspr, 0, sizeof(diggingspr));
10316 76 memset(usingrodspr, 0, sizeof(usingrodspr));
10317 76 memset(usingcanespr, 0, sizeof(usingcanespr));
10318 76 memset(pushingspr, 0, sizeof(pushingspr));
10319 76 memset(liftingspr, 0, sizeof(liftingspr));
10320 76 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10321 76 memset(stunnedspr, 0, sizeof(stunnedspr));
10322 76 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10323 76 memset(fallingspr, 0, sizeof(fallingspr));
10324 76 memset(shockedspr, 0, sizeof(shockedspr));
10325 76 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10326 76 memset(pullswordspr, 0, sizeof(pullswordspr));
10327 76 memset(readingspr, 0, sizeof(readingspr));
10328 76 memset(slash180spr, 0, sizeof(slash180spr));
10329 76 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10330 76 memset(dashspr, 0, sizeof(dashspr));
10331 76 memset(bonkspr, 0, sizeof(bonkspr));
10332 76 memset(medallionsprs, 0, sizeof(medallionsprs));
10333 76 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10334 76 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10335
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t q = 0; q < 4; ++q)
10336 {
10337
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 304 times.
1216 for(int32_t p = 0; p < 3; ++p)
10338 {
10339 912 drowningspr[q][p] = divespr[q][p];
10340 912 drowning_lavaspr[q][p] = divespr[q][p];
10341 912 }
10342 304 }
10343 76 memset(sideswimspr, 0, sizeof(sideswimspr));
10344 76 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10345 76 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10346 76 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10347 76 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10348 76 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10349 76 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10350 76 }
10351 76 }
10352
10353
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
89 if(keepdata && FFCore.quest_format[vInitData] < 34)
10354 {
10355 89 bool fastswim = zinit.hero_swim_speed > 60;
10356 // '2/3' or '1/2'
10357 89 zinit.hero_swim_mult = fastswim ? 2 : 1;
10358 89 zinit.hero_swim_div = fastswim ? 3 : 2;
10359 89 }
10360 89 return 0;
10361 89 }
10362
10363 3910 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10364 {
10365 3910 arr[spr_tile] = tile;
10366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3910 times.
3910 arr[spr_flip] = (flip > 3 ? 0 : flip);
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3910 times.
3910 arr[spr_extend] = (ext > 2 ? 0 : ext);
10368 3910 }
10369 //Used to read the player sprites as int32_t, not word.
10370 23 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10371 {
10372 //these are here to bypass compiler warnings about unused arguments
10373 23 cv_herosprites=cv_herosprites;
10374
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10376 {
10377 23 zinit.hero_swim_speed=67; //default
10378 23 setupherotiles(zinit.heroAnimationStyle);
10379 23 setupherodefenses();
10380 23 setupherooffsets();
10381 23 }
10382
10383 int32_t tile, tile2;
10384 byte flip, extend, dummy_byte;
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>=0)
10387 {
10388
10389
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10390 {
10391
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10392 {
10393 return qe_invalid;
10394 }
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10397 {
10398 return qe_invalid;
10399 }
10400
10401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10402 {
10403 return qe_invalid;
10404 }
10405
10406 92 if(keepdata)
10407 {
10408 92 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10409 92 }
10410 92 }
10411
10412
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10413 {
10414
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10415 {
10416 return qe_invalid;
10417 }
10418
10419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10420 {
10421 return qe_invalid;
10422 }
10423
10424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10430 {
10431 92 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10432 92 }
10433 92 }
10434
10435
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10436 {
10437
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10438 {
10439 return qe_invalid;
10440 }
10441
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10443 {
10444 return qe_invalid;
10445 }
10446
10447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10448 {
10449 return qe_invalid;
10450 }
10451
10452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10453 {
10454 92 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10455 92 }
10456 92 }
10457
10458
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10459 {
10460
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10461 {
10462 return qe_invalid;
10463 }
10464
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10466 {
10467 return qe_invalid;
10468 }
10469
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10471 {
10472 return qe_invalid;
10473 }
10474
10475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10476 {
10477 92 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10478 92 }
10479 92 }
10480
10481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>1)
10482 {
10483
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10484 {
10485
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10486 {
10487 return qe_invalid;
10488 }
10489
10490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10491 {
10492 return qe_invalid;
10493 }
10494
10495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10496 {
10497 return qe_invalid;
10498 }
10499
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10501 {
10502 92 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10503 92 }
10504 92 }
10505 23 }
10506
10507
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10508 {
10509
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10515 {
10516 return qe_invalid;
10517 }
10518
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10520 {
10521 return qe_invalid;
10522 }
10523
10524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10525 {
10526 92 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10527 92 }
10528 92 }
10529
10530
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10531 {
10532
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10533 {
10534 return qe_invalid;
10535 }
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10538 {
10539 return qe_invalid;
10540 }
10541
10542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10543 {
10544 return qe_invalid;
10545 }
10546
10547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10548 {
10549 92 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10550 92 }
10551 92 }
10552
10553
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tile,f,keepdata))
10554 {
10555 return qe_invalid;
10556 }
10557
10558 23 flip=0;
10559
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>0)
10561 {
10562
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&flip,f,keepdata))
10563 {
10564 return qe_invalid;
10565 }
10566 23 }
10567
10568
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&extend,f,keepdata))
10569 {
10570 return qe_invalid;
10571 }
10572
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10574 {
10575 23 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10576 23 }
10577
10578
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(v_herosprites>0)
10579 {
10580 23 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10581
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for(int32_t i=0; i<2; i++)
10582 {
10583
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 46 times.
184 for(int32_t j=0; j<num_holdsprs; j++)
10584 {
10585
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(!p_igetl(&tile,f,keepdata))
10586 {
10587 return qe_invalid;
10588 }
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!p_getc(&flip,f,keepdata))
10591 {
10592 return qe_invalid;
10593 }
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!p_getc(&extend,f,keepdata))
10596 {
10597 return qe_invalid;
10598 }
10599
10600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(keepdata)
10601 {
10602 138 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10603 138 }
10604 138 }
10605 46 }
10606 23 }
10607 else
10608 {
10609 for(int32_t i=0; i<2; i++)
10610 {
10611 if(!p_igetl(&tile,f,keepdata))
10612 {
10613 return qe_invalid;
10614 }
10615
10616 if(!p_igetl(&tile2,f,keepdata))
10617 {
10618 return qe_invalid;
10619 }
10620
10621 if(!p_getc(&extend,f,keepdata))
10622 {
10623 return qe_invalid;
10624 }
10625
10626 if(keepdata)
10627 {
10628 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10629 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10630 }
10631 }
10632 }
10633
10634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>2)
10635 {
10636
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10637 {
10638
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10639 {
10640 return qe_invalid;
10641 }
10642
10643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10644 {
10645 return qe_invalid;
10646 }
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10649 {
10650 return qe_invalid;
10651 }
10652
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10654 {
10655 92 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10656 92 }
10657 92 }
10658 23 }
10659
10660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>3)
10661 {
10662
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10663 {
10664
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10665 {
10666 return qe_invalid;
10667 }
10668
10669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10670 {
10671 return qe_invalid;
10672 }
10673
10674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10675 {
10676 return qe_invalid;
10677 }
10678
10679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10680 {
10681 92 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10682 92 }
10683 92 }
10684 23 }
10685
10686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>4)
10687 {
10688
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&dummy_byte,f,keepdata))
10689 {
10690 return qe_invalid;
10691 }
10692
10693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10694 {
10695 23 zinit.hero_swim_speed=(byte)dummy_byte;
10696 23 }
10697 23 }
10698
10699
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(v_herosprites>6)
10700 {
10701
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10702 {
10703
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10704 return qe_invalid;
10705
10706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10707 return qe_invalid;
10708
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10710 return qe_invalid;
10711
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10713 {
10714 92 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10715 92 }
10716 92 }
10717
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10718 {
10719
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10720 return qe_invalid;
10721
10722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10723 return qe_invalid;
10724
10725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10726 return qe_invalid;
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10729 {
10730 92 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10731 92 }
10732 92 }
10733
10734
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10735 {
10736
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10737 return qe_invalid;
10738
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10740 return qe_invalid;
10741
10742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10743 return qe_invalid;
10744
10745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10746 {
10747 92 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10748 92 }
10749 92 }
10750
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10751 {
10752
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10753 return qe_invalid;
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10759 return qe_invalid;
10760
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10762 {
10763 92 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10764 92 }
10765 92 }
10766
10767
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10768 {
10769
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10770 return qe_invalid;
10771
10772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10773 return qe_invalid;
10774
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10776 return qe_invalid;
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10779 {
10780 92 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10781 92 }
10782 92 }
10783
10784
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10785 {
10786
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10790 return qe_invalid;
10791
10792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10793 return qe_invalid;
10794
10795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10796 {
10797 92 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10798 92 }
10799 92 }
10800
10801
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10802 {
10803
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10804 return qe_invalid;
10805
10806
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10807 return qe_invalid;
10808
10809
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10810 return qe_invalid;
10811
10812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10813 {
10814 92 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10815 92 }
10816 92 }
10817
10818
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10819 {
10820
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10821 return qe_invalid;
10822
10823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10824 return qe_invalid;
10825
10826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10827 return qe_invalid;
10828
10829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10830 {
10831 92 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10832 92 }
10833 92 }
10834
10835
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10836 {
10837
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10838 return qe_invalid;
10839
10840
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10841 return qe_invalid;
10842
10843
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10844 return qe_invalid;
10845
10846 92 byte frames = 0;
10847
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 84 times.
92 if(v_herosprites > 15)
10848 {
10849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!p_getc(&frames,f,keepdata))
10850 return qe_invalid;
10851 84 }
10852
10853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10854 {
10855 92 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 92 liftingspr[q][spr_frames] = frames;
10857 92 }
10858 92 }
10859
10860
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10861 {
10862
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10863 return qe_invalid;
10864
10865
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10866 return qe_invalid;
10867
10868
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10869 return qe_invalid;
10870
10871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10872 {
10873 92 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10874 92 }
10875 92 }
10876
10877
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10878 {
10879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&tile,f,keepdata))
10880 return qe_invalid;
10881
10882
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10883 return qe_invalid;
10884
10885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10886 return qe_invalid;
10887
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10889 {
10890 92 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10891 92 }
10892 92 }
10893
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10894 {
10895
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10899 return qe_invalid;
10900
10901
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10905 {
10906 92 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10907 92 }
10908 92 }
10909
10910
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10911 {
10912
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10916 return qe_invalid;
10917
10918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10919 return qe_invalid;
10920
10921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10922 {
10923 92 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10924 92 }
10925 92 }
10926
10927
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10928 {
10929
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10933 return qe_invalid;
10934
10935
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10936 return qe_invalid;
10937
10938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10939 {
10940 92 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10941 92 }
10942 92 }
10943
10944
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10945 {
10946
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10950 return qe_invalid;
10951
10952
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10953 return qe_invalid;
10954
10955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10956 {
10957 92 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10958 92 }
10959 92 }
10960
10961
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10962 {
10963
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10964 return qe_invalid;
10965
10966
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10970 return qe_invalid;
10971
10972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10973 {
10974 92 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10975 92 }
10976 92 }
10977
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10978 {
10979
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10980 return qe_invalid;
10981
10982
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10983 return qe_invalid;
10984
10985
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10986 return qe_invalid;
10987
10988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10989 {
10990 92 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10991 92 }
10992 92 }
10993
10994
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10995 {
10996
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10997 return qe_invalid;
10998
10999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11000 return qe_invalid;
11001
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11003 return qe_invalid;
11004
11005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11006 {
11007 92 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11008 92 }
11009 92 }
11010
11011
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11012 {
11013
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11014 return qe_invalid;
11015
11016
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
11017 return qe_invalid;
11018
11019
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
11020 return qe_invalid;
11021
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11023 {
11024 92 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11025 92 }
11026 92 }
11027
11028
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11029 {
11030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&tile,f,keepdata))
11031 return qe_invalid;
11032
11033
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
11034 return qe_invalid;
11035
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11040 {
11041 92 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11042 92 }
11043 92 }
11044
11045
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11046 {
11047
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11048 return qe_invalid;
11049
11050
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
11051 return qe_invalid;
11052
11053
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
11054 return qe_invalid;
11055
11056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11057 {
11058 92 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11059 92 }
11060 92 }
11061
11062
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11063 {
11064
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11065 return qe_invalid;
11066
11067
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
11068 return qe_invalid;
11069
11070
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
11071 return qe_invalid;
11072
11073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11074 {
11075 92 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11076 92 }
11077 92 }
11078
11079
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11080 {
11081
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11082 return qe_invalid;
11083
11084
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
11085 return qe_invalid;
11086
11087
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
11088 return qe_invalid;
11089
11090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11091 {
11092 92 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11093 92 }
11094 92 }
11095
11096
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11097 {
11098
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetl(&tile,f,keepdata))
11099 return qe_invalid;
11100
11101
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_getc(&flip,f,keepdata))
11102 return qe_invalid;
11103
11104
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_getc(&extend,f,keepdata))
11105 return qe_invalid;
11106
11107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(keepdata)
11108 {
11109 69 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11110 69 }
11111 69 }
11112 23 }
11113 else if(keepdata)
11114 {
11115 memset(frozenspr, 0, sizeof(frozenspr));
11116 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11117 memset(onfirespr, 0, sizeof(onfirespr));
11118 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11119 memset(diggingspr, 0, sizeof(diggingspr));
11120 memset(usingrodspr, 0, sizeof(usingrodspr));
11121 memset(usingcanespr, 0, sizeof(usingcanespr));
11122 memset(pushingspr, 0, sizeof(pushingspr));
11123 memset(liftingspr, 0, sizeof(liftingspr));
11124 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11125 memset(stunnedspr, 0, sizeof(stunnedspr));
11126 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11127 memset(fallingspr, 0, sizeof(fallingspr));
11128 memset(shockedspr, 0, sizeof(shockedspr));
11129 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11130 memset(pullswordspr, 0, sizeof(pullswordspr));
11131 memset(readingspr, 0, sizeof(readingspr));
11132 memset(slash180spr, 0, sizeof(slash180spr));
11133 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11134 memset(dashspr, 0, sizeof(dashspr));
11135 memset(bonkspr, 0, sizeof(bonkspr));
11136 memset(medallionsprs, 0, sizeof(medallionsprs));
11137 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11138 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11139 for(int32_t q = 0; q < 4; ++q)
11140 {
11141 for(int32_t p = 0; p < 3; ++p)
11142 {
11143 drowningspr[q][p] = divespr[q][p];
11144 drowning_lavaspr[q][p] = divespr[q][p];
11145 }
11146 }
11147 }
11148
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 8)
11149 {
11150
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11151 {
11152
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11153 return qe_invalid;
11154
11155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11156 return qe_invalid;
11157
11158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11159 return qe_invalid;
11160
11161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11162 {
11163 92 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11164 92 }
11165 92 }
11166 23 }
11167 else if (keepdata)
11168 {
11169 memset(sideswimspr, 0, sizeof(sideswimspr));
11170 }
11171
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 9)
11172 {
11173
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11174 {
11175
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11176 return qe_invalid;
11177
11178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11185 {
11186 92 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11187 92 }
11188 92 }
11189
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11190 {
11191
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11192 return qe_invalid;
11193
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11195 return qe_invalid;
11196
11197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11198 return qe_invalid;
11199
11200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11201 {
11202 92 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11203 92 }
11204 92 }
11205
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11206 {
11207
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11208 return qe_invalid;
11209
11210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11211 return qe_invalid;
11212
11213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11214 return qe_invalid;
11215
11216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11217 {
11218 92 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11219 92 }
11220 92 }
11221
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11222 {
11223
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11224 return qe_invalid;
11225
11226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11227 return qe_invalid;
11228
11229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11230 return qe_invalid;
11231
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11233 {
11234 92 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11235 92 }
11236 92 }
11237 23 }
11238 else if (keepdata)
11239 {
11240 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11241 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11242 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11243 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11244 }
11245
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 10)
11246 {
11247
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11248 {
11249 int32_t hmr;
11250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&hmr,f,keepdata))
11251 return qe_invalid;
11252
11253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11254 {
11255 92 hammeroffsets[q] = hmr;
11256 92 }
11257 92 }
11258 23 }
11259 else if (keepdata)
11260 {
11261 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11262 }
11263
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 11)
11264 {
11265
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for(int32_t q = 0; q < 3; ++q)
11266 {
11267
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetl(&tile,f,keepdata))
11268 return qe_invalid;
11269
11270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&flip,f,keepdata))
11271 return qe_invalid;
11272
11273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&extend,f,keepdata))
11274 return qe_invalid;
11275
11276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(keepdata)
11277 {
11278 69 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11279 69 }
11280 69 }
11281 23 }
11282 else if (keepdata)
11283 {
11284 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11285 }
11286
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 12)
11287 {
11288
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tile,f,keepdata))
11289 return qe_invalid;
11290
11291
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&flip,f,keepdata))
11292 return qe_invalid;
11293
11294
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&extend,f,keepdata))
11295 return qe_invalid;
11296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if (keepdata)
11297 {
11298 23 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11299 23 }
11300
11301 23 }
11302 else if (keepdata)
11303 {
11304 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11305 }
11306
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 13)
11307 {
11308
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11309 {
11310
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11311 return qe_invalid;
11312
11313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11314 return qe_invalid;
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11317 return qe_invalid;
11318
11319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11320 {
11321 92 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11322 92 }
11323 92 }
11324 23 }
11325 else if (keepdata)
11326 {
11327 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11328 }
11329
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 14)
11330 {
11331
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11332 {
11333
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11334 return qe_invalid;
11335
11336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11337 return qe_invalid;
11338
11339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11340 return qe_invalid;
11341
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11343 {
11344 92 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11345 92 }
11346 92 }
11347 23 }
11348 else if (keepdata)
11349 {
11350 memset(revslashspr, 0, sizeof(revslashspr));
11351 }
11352
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 7)
11353 {
11354 23 int32_t num_defense = wMax;
11355 23 byte def = 0;
11356
11357 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11358 /*if(v_herosprites > [x])
11359 * {
11360 * num_defense = 146 //value of wMax on version 8
11361 * }
11362 */
11363
11364
2/2
✓ Branch 0 taken 3358 times.
✓ Branch 1 taken 23 times.
3381 for (int32_t q = 0; q < num_defense; q++)
11365 {
11366
1/2
✓ Branch 0 taken 3358 times.
✗ Branch 1 not taken.
3358 if (!p_getc(&def, f, keepdata))
11367 return qe_invalid;
11368
11369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (keepdata)
11370 {
11371 3358 hero_defence[q] = def;
11372 3358 }
11373 3358 }
11374 23 }
11375 else if (keepdata)
11376 {
11377 int32_t num_defense = wMax;
11378 for (int32_t q = 0; q < num_defense; q++)
11379 {
11380 hero_defence[q] = 0;
11381 }
11382 }
11383 23 }
11384
11385
3/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 14 times.
23 if(keepdata && FFCore.quest_format[vInitData] < 34)
11386 {
11387 14 bool fastswim = zinit.hero_swim_speed > 60;
11388 // '2/3' or '1/2'
11389 14 zinit.hero_swim_mult = fastswim ? 2 : 1;
11390 14 zinit.hero_swim_div = fastswim ? 3 : 2;
11391 14 }
11392 23 return 0;
11393 23 }
11394
11395
11396 99 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11397 {
11398 //these are here to bypass compiler warnings about unused arguments
11399 99 Header=Header;
11400
11401 dword dummy;
11402 99 word s_version=0, s_cversion=0;
11403
11404 //section version info
11405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
11406 {
11407 return qe_invalid;
11408 }
11409
11410 99 FFCore.quest_format[vHeroSprites] = s_version;
11411
11412 //al_trace("Player sprites version %d\n", s_version);
11413
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
11414 {
11415 return qe_invalid;
11416 }
11417
11418 //section size
11419
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
11420 {
11421 return qe_invalid;
11422 }
11423
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if ( s_version >= 6 )
11424 {
11425 //al_trace("Reading Player Sprites v6\n");
11426 23 return readherosprites3(f, s_version, dummy, keepdata);
11427 }
11428 76 else return readherosprites2(f, s_version, dummy, keepdata);
11429 99 }
11430
11431 99 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11432 {
11433 int32_t dummy;
11434 99 word s_version=0, s_cversion=0;
11435
11436 //section version info
11437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
11438 {
11439 return qe_invalid;
11440 }
11441
11442 99 FFCore.quest_format[vSubscreen] = s_version;
11443
11444 //al_trace("Subscreens version %d\n", s_version);
11445
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
11446 {
11447 return qe_invalid;
11448 }
11449
11450 //section size
11451
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
11452 {
11453 return qe_invalid;
11454 }
11455
11456 //finally... section data
11457
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 99 times.
12771 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11458 {
11459 12672 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11460
11461
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(ret!=0) return ret;
11462 12672 }
11463
11464 99 return 0;
11465 99 }
11466
11467 12672 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11468 {
11469 12672 int32_t numsub=0;
11470 12672 byte temp_ss=0;
11471 subscreen_object temp_sub_stack;
11472 12672 subscreen_object *temp_sub = &temp_sub_stack;
11473
11474 char tempname[64];
11475
11476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(!pfread(tempname,64,f,true))
11477 {
11478 return qe_invalid;
11479 }
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(s_version > 1)
11482 {
11483
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(!p_getc(&temp_ss,f,keepdata))
11484 {
11485 return qe_invalid;
11486 }
11487 12672 }
11488
11489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(s_version < 4)
11490 {
11491 uint8_t tmp=0;
11492
11493 if(!p_getc(&tmp,f,true))
11494 {
11495 return qe_invalid;
11496 }
11497
11498 numsub = (int32_t)tmp;
11499 }
11500 else
11501 {
11502 word tmp;
11503
11504
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(!p_igetw(&tmp, f, true))
11505 {
11506 return qe_invalid;
11507 }
11508
11509 12672 numsub = (int32_t)tmp;
11510 }
11511
11512 int32_t j;
11513
11514
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33156 times.
✓ Branch 2 taken 20484 times.
✓ Branch 3 taken 12672 times.
33156 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11515 {
11516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20484 times.
20484 if(keepdata)
11517 {
11518 20484 memset(temp_sub,0,sizeof(subscreen_object));
11519
11520
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 19300 times.
20484 switch(custom_subscreen[i].objects[j].type)
11521 {
11522 case ssoTEXT:
11523 case ssoTEXTBOX:
11524 case ssoCURRENTITEMTEXT:
11525 case ssoCURRENTITEMCLASSTEXT:
11526
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
✓ Branch 2 taken 1184 times.
✗ Branch 3 not taken.
1184 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11527
11528 //fall through
11529 default:
11530 20484 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11531 20484 break;
11532 }
11533 20484 }
11534
11535
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->type),f,true))
11536 {
11537 return qe_invalid;
11538 }
11539
11540
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->pos),f,keepdata))
11541 {
11542 return qe_invalid;
11543 }
11544
11545
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(s_version < 5)
11546 {
11547 switch(temp_sub->pos)
11548 {
11549 case 0:
11550 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11551 break;
11552
11553 case 1:
11554 temp_sub->pos = sspUP;
11555 break;
11556
11557 case 2:
11558 temp_sub->pos = sspDOWN;
11559 break;
11560
11561 default:
11562 temp_sub->pos = 0;
11563 }
11564 }
11565
11566
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->x),f,keepdata))
11567 {
11568 return qe_invalid;
11569 }
11570
11571
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->y),f,keepdata))
11572 {
11573 return qe_invalid;
11574 }
11575
11576
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->w),f,keepdata))
11577 {
11578 return qe_invalid;
11579 }
11580
11581
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->h),f,keepdata))
11582 {
11583 return qe_invalid;
11584 }
11585
11586
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11587 {
11588 return qe_invalid;
11589 }
11590
11591
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11592 {
11593 return qe_invalid;
11594 }
11595
11596
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11597 {
11598 return qe_invalid;
11599 }
11600
11601
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11602 {
11603 return qe_invalid;
11604 }
11605
11606
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11607 {
11608 return qe_invalid;
11609 }
11610
11611
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11612 {
11613 return qe_invalid;
11614 }
11615
11616
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11617 {
11618 return qe_invalid;
11619 }
11620
11621
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11622 {
11623 return qe_invalid;
11624 }
11625
11626
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11627 {
11628 return qe_invalid;
11629 }
11630
11631
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11632 {
11633 return qe_invalid;
11634 }
11635
11636
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11637 {
11638 return qe_invalid;
11639 }
11640
11641
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11642 {
11643 return qe_invalid;
11644 }
11645
11646
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11647 {
11648 return qe_invalid;
11649 }
11650
11651
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11652 {
11653 return qe_invalid;
11654 }
11655
11656
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11657 {
11658 return qe_invalid;
11659 }
11660
11661
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11662 {
11663 return qe_invalid;
11664 }
11665
11666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20484 times.
20484 if(s_version < 2)
11667 {
11668 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11669 {
11670 return qe_invalid;
11671 }
11672
11673 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11674 {
11675 return qe_invalid;
11676 }
11677
11678 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11679 {
11680 return qe_invalid;
11681 }
11682 }
11683 else
11684 {
11685
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->speed),f,keepdata))
11686 {
11687 return qe_invalid;
11688 }
11689
11690
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_getc(&(temp_sub->delay),f,keepdata))
11691 {
11692 return qe_invalid;
11693 }
11694
11695
1/2
✓ Branch 0 taken 20484 times.
✗ Branch 1 not taken.
20484 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11696 {
11697 return qe_invalid;
11698 }
11699 }
11700
11701 20484 int32_t temp_size=0;
11702
11703 // bool deletets = false;
11704
4/4
✓ Branch 0 taken 8629 times.
✓ Branch 1 taken 1650 times.
✓ Branch 2 taken 10060 times.
✓ Branch 3 taken 145 times.
20484 switch(temp_sub->type)
11705 {
11706 case ssoTEXT:
11707 case ssoTEXTBOX:
11708 case ssoCURRENTITEMTEXT:
11709 case ssoCURRENTITEMCLASSTEXT:
11710 word temptempsize;
11711 /*uint8_t temp1;
11712 uint8_t temp2;
11713 temp2 = 0;
11714 if(!p_getc(&temp1,f,true))
11715 {
11716 return qe_invalid;
11717 }
11718 if(temp1)
11719 {
11720
11721 if(!p_getc(&temp2,f,true))
11722 {
11723 return qe_invalid;
11724 }
11725 }*/
11726
11727
1/2
✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
1650 if(!p_igetw(&temptempsize,f,true))
11728 {
11729 return qe_invalid;
11730 }
11731
11732 //temptempsize = temp1 + (temp2 << 8);
11733 1650 temp_size = (int32_t)temptempsize;
11734
11735 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1650 times.
1650 if(keepdata)
11737 {
11738 1650 uint32_t char_length = temp_size+1;
11739 1650 temp_sub->dp1 = new char[char_length]; //memory not freed
11740
11741 //deletets = true; //obsolete
11742 1650 }
11743
11744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1650 times.
1650 if(temp_size)
11745 {
11746
1/2
✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
1650 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11747 {
11748 return qe_invalid;
11749 }
11750 1650 }
11751
11752 1650 break;
11753
11754 case ssoLIFEMETER:
11755
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11756 temp_sub->d3 = 1;
11757
11758
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11759 {
11760 return qe_invalid;
11761 }
11762
11763 145 break;
11764
11765
11766 case ssoCURRENTITEM:
11767
11768
1/2
✓ Branch 0 taken 8629 times.
✗ Branch 1 not taken.
8629 if(s_version < 6)
11769 {
11770 switch(temp_sub->d1)
11771 {
11772 case ssiBOMB:
11773 temp_sub->d1 = itype_bomb;
11774 break;
11775
11776 case ssiSWORD:
11777 temp_sub->d1 = itype_sword;
11778 break;
11779
11780 case ssiSHIELD:
11781 temp_sub->d1 = itype_shield;
11782 break;
11783
11784 case ssiCANDLE:
11785 temp_sub->d1 = itype_candle;
11786 break;
11787
11788 case ssiLETTER:
11789 temp_sub->d1 = itype_letter;
11790 break;
11791
11792 case ssiPOTION:
11793 temp_sub->d1 = itype_potion;
11794 break;
11795
11796 case ssiLETTERPOTION:
11797 temp_sub->d1 = itype_letterpotion;
11798 break;
11799
11800 case ssiBOW:
11801 temp_sub->d1 = itype_bow;
11802 break;
11803
11804 case ssiARROW:
11805 temp_sub->d1 = itype_arrow;
11806 break;
11807
11808 case ssiBOWANDARROW:
11809 temp_sub->d1 = itype_bowandarrow;
11810 break;
11811
11812 case ssiBAIT:
11813 temp_sub->d1 = itype_bait;
11814 break;
11815
11816 case ssiRING:
11817 temp_sub->d1 = itype_ring;
11818 break;
11819
11820 case ssiBRACELET:
11821 temp_sub->d1 = itype_bracelet;
11822 break;
11823
11824 case ssiMAP:
11825 temp_sub->d1 = itype_map;
11826 break;
11827
11828 case ssiCOMPASS:
11829 temp_sub->d1 = itype_compass;
11830 break;
11831
11832 case ssiBOSSKEY:
11833 temp_sub->d1 = itype_bosskey;
11834 break;
11835
11836 case ssiMAGICKEY:
11837 temp_sub->d1 = itype_magickey;
11838 break;
11839
11840 case ssiBRANG:
11841 temp_sub->d1 = itype_brang;
11842 break;
11843
11844 case ssiWAND:
11845 temp_sub->d1 = itype_wand;
11846 break;
11847
11848 case ssiRAFT:
11849 temp_sub->d1 = itype_raft;
11850 break;
11851
11852 case ssiLADDER:
11853 temp_sub->d1 = itype_ladder;
11854 break;
11855
11856 case ssiWHISTLE:
11857 temp_sub->d1 = itype_whistle;
11858 break;
11859
11860 case ssiBOOK:
11861 temp_sub->d1 = itype_book;
11862 break;
11863
11864 case ssiWALLET:
11865 temp_sub->d1 = itype_wallet;
11866 break;
11867
11868 case ssiSBOMB:
11869 temp_sub->d1 = itype_sbomb;
11870 break;
11871
11872 case ssiHCPIECE:
11873 temp_sub->d1 = itype_heartpiece;
11874 break;
11875
11876 case ssiAMULET:
11877 temp_sub->d1 = itype_amulet;
11878 break;
11879
11880 case ssiFLIPPERS:
11881 temp_sub->d1 = itype_flippers;
11882 break;
11883
11884 case ssiHOOKSHOT:
11885 temp_sub->d1 = itype_hookshot;
11886 break;
11887
11888 case ssiLENS:
11889 temp_sub->d1 = itype_lens;
11890 break;
11891
11892 case ssiHAMMER:
11893 temp_sub->d1 = itype_hammer;
11894 break;
11895
11896 case ssiBOOTS:
11897 temp_sub->d1 = itype_boots;
11898 break;
11899
11900 case ssiDIVINEFIRE:
11901 temp_sub->d1 = itype_divinefire;
11902 break;
11903
11904 case ssiDIVINEESCAPE:
11905 temp_sub->d1 = itype_divineescape;
11906 break;
11907
11908 case ssiDIVINEPROTECTION:
11909 temp_sub->d1 = itype_divineprotection;
11910 break;
11911
11912 case ssiQUIVER:
11913 temp_sub->d1 = itype_quiver;
11914 break;
11915
11916 case ssiBOMBBAG:
11917 temp_sub->d1 = itype_bombbag;
11918 break;
11919
11920 case ssiCBYRNA:
11921 temp_sub->d1 = itype_cbyrna;
11922 break;
11923
11924 case ssiROCS:
11925 temp_sub->d1 = itype_rocs;
11926 break;
11927
11928 case ssiHOVERBOOTS:
11929 temp_sub->d1 = itype_hoverboots;
11930 break;
11931
11932 case ssiSPINSCROLL:
11933 temp_sub->d1 = itype_spinscroll;
11934 break;
11935
11936 case ssiCROSSSCROLL:
11937 temp_sub->d1 = itype_crossscroll;
11938 break;
11939
11940 case ssiQUAKESCROLL:
11941 temp_sub->d1 = itype_quakescroll;
11942 break;
11943
11944 case ssiWHISPRING:
11945 temp_sub->d1 = itype_whispring;
11946 break;
11947
11948 case ssiCHARGERING:
11949 temp_sub->d1 = itype_chargering;
11950 break;
11951
11952 case ssiPERILSCROLL:
11953 temp_sub->d1 = itype_perilscroll;
11954 break;
11955
11956 case ssiWEALTHMEDAL:
11957 temp_sub->d1 = itype_wealthmedal;
11958 break;
11959
11960 case ssiHEARTRING:
11961 temp_sub->d1 = itype_heartring;
11962 break;
11963
11964 case ssiMAGICRING:
11965 temp_sub->d1 = itype_magicring;
11966 break;
11967
11968 case ssiSPINSCROLL2:
11969 temp_sub->d1 = itype_spinscroll2;
11970 break;
11971
11972 case ssiQUAKESCROLL2:
11973 temp_sub->d1 = itype_quakescroll2;
11974 break;
11975
11976 case ssiAGONY:
11977 temp_sub->d1 = itype_agony;
11978 break;
11979
11980 case ssiSTOMPBOOTS:
11981 temp_sub->d1 = itype_stompboots;
11982 break;
11983
11984 case ssiWHIMSICALRING:
11985 temp_sub->d1 = itype_whimsicalring;
11986 break;
11987
11988 case ssiPERILRING:
11989 temp_sub->d1 = itype_perilring;
11990 break;
11991
11992 default:
11993 temp_sub->d1 += itype_custom1 - ssiMAX;
11994 }
11995 }
11996
11997 //fall-through
11998 default:
11999
1/2
✓ Branch 0 taken 18689 times.
✗ Branch 1 not taken.
18689 if(!p_getc(&(temp_sub->dp1),f,keepdata))
12000 {
12001 return qe_invalid;
12002 }
12003
12004 18689 break;
12005 }
12006
12007
2/2
✓ Branch 0 taken 11884 times.
✓ Branch 1 taken 8600 times.
20484 if(s_version < 7)
12008 {
12009
3/3
✓ Branch 0 taken 7941 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8600 switch(temp_sub->type)
12010 {
12011 case ssoMAGICGAUGE:
12012 {
12013
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
12014 192 temp_sub->d9 = -1; //-1 now represents 'always'
12015 227 break;
12016 }
12017 case ssoLIFEGAUGE:
12018 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12019 432 break;
12020 }
12021 8600 }
12022
12023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20484 times.
20484 if(keepdata)
12024 {
12025
3/3
✓ Branch 0 taken 1650 times.
✓ Branch 1 taken 17956 times.
✓ Branch 2 taken 878 times.
20484 switch(temp_sub->type)
12026 {
12027 case ssoTEXT:
12028 case ssoTEXTBOX:
12029 case ssoCURRENTITEMTEXT:
12030 case ssoCURRENTITEMCLASSTEXT:
12031
1/4
✓ Branch 0 taken 1650 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1650 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
12032
12033 1650 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12034 1650 custom_subscreen[i].objects[j].dp1 = NULL;
12035 1650 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
12036 1650 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
12037 1650 break;
12038
12039 case ssoCOUNTER:
12040
1/2
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
878 if(s_version<3)
12041 {
12042 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12043 temp_sub->d8=0;
12044 }
12045
12046 default:
12047 18834 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12048 18834 break;
12049 }
12050
12051 20484 strcpy(custom_subscreen[i].name, tempname);
12052 20484 custom_subscreen[i].ss_type = temp_ss;
12053 20484 }
12054 20484 }
12055
12056
2/2
✓ Branch 0 taken 3223548 times.
✓ Branch 1 taken 12672 times.
3236220 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12057 {
12058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3223548 times.
3223548 if(keepdata)
12059 {
12060 //clear all unused object in this subscreen -DD
12061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3223548 times.
3223548 switch(custom_subscreen[i].objects[j].type)
12062 {
12063 case ssoTEXT:
12064 case ssoTEXTBOX:
12065 case ssoCURRENTITEMTEXT:
12066 case ssoCURRENTITEMCLASSTEXT:
12067 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12068
12069 //fall through
12070 default:
12071 3223548 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12072 3223548 break;
12073 }
12074 3223548 }
12075 3223548 }
12076
12077 12672 return 0;
12078 12672 }
12079
12080 2944 void reset_subscreen(subscreen_group *tempss)
12081 {
12082
2/2
✓ Branch 0 taken 753664 times.
✓ Branch 1 taken 2944 times.
756608 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12083 {
12084
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 753522 times.
753664 switch(tempss->objects[i].type)
12085 {
12086 case ssoTEXT:
12087 case ssoTEXTBOX:
12088 case ssoCURRENTITEMTEXT:
12089 case ssoCURRENTITEMCLASSTEXT:
12090
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12091
12092 //fall through
12093 default:
12094 753664 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12095 753664 break;
12096 }
12097 753664 }
12098 2944 }
12099
12100 23 void reset_subscreens()
12101 {
12102
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 23 times.
2967 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12103 {
12104 2944 reset_subscreen(&custom_subscreen[i]);
12105 2944 }
12106 23 }
12107
12108 23 int32_t setupsubscreens()
12109 {
12110 23 reset_subscreens();
12111 23 int32_t tempsubscreen=zinit.subscreen;
12112 subscreen_object *tempsub;
12113
12114
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tempsubscreen>=ssdtMAX)
12115 {
12116 tempsubscreen=0;
12117 }
12118
12119
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 switch(tempsubscreen)
12120 {
12121 case ssdtOLD:
12122 case ssdtNEWSUBSCR:
12123 case ssdtREV2:
12124 case ssdtBSZELDA:
12125 case ssdtBSZELDAMODIFIED:
12126 case ssdtBSZELDAENHANCED:
12127 case ssdtBSZELDACOMPLETE:
12128 {
12129 23 tempsub = default_subscreen_active[tempsubscreen][0];
12130 int32_t i;
12131
12132
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12133 {
12134
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1431 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12135 {
12136 case ssoTEXT:
12137 case ssoTEXTBOX:
12138 case ssoCURRENTITEMTEXT:
12139 case ssoCURRENTITEMCLASSTEXT:
12140
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12141
12142 64 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12143 64 custom_subscreen[0].objects[i].dp1 = NULL;
12144 64 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12145 64 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12146 64 break;
12147
12148 case ssoLIFEMETER:
12149 {
12150 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12151
12152 if(get_bit(deprecated_rules, 12) != 0)
12153 custom_subscreen[0].objects[i].d3=1;
12154 else
12155 custom_subscreen[0].objects[i].d3=0;
12156
12157 break;
12158 }
12159 /*
12160 case ssoTRIFRAME:
12161 {
12162 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12163 custom_subscreen[0].objects[i].d1 = 8594;
12164 custom_subscreen[0].objects[i].d2 = 8;
12165 custom_subscreen[0].objects[i].d3 = 8771;
12166 custom_subscreen[0].objects[i].d4 = 8;
12167 custom_subscreen[0].objects[i].d5 = 1;
12168 custom_subscreen[0].objects[i].d6 = 1;
12169 break;
12170 }*/
12171
12172 default:
12173 1431 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12174 1431 break;
12175 }
12176 1495 }
12177
12178 23 custom_subscreen[0].ss_type=sstACTIVE;
12179 23 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12180 23 tempsub = default_subscreen_active[tempsubscreen][1];
12181
12182
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12183 {
12184
2/3
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1412 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12185 {
12186 case ssoTEXT:
12187 case ssoTEXTBOX:
12188 case ssoCURRENTITEMTEXT:
12189 case ssoCURRENTITEMCLASSTEXT:
12190
1/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12191
12192 83 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12193 83 custom_subscreen[1].objects[i].dp1 = NULL;
12194 83 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12195 83 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12196 83 break;
12197
12198 case ssoLIFEMETER:
12199 {
12200 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12201
12202 if(get_bit(deprecated_rules, 12) != 0)
12203 custom_subscreen[1].objects[i].d3=1;
12204 else
12205 custom_subscreen[1].objects[i].d3=0;
12206
12207 break;
12208 }
12209 /*
12210 case ssoTRIFRAME:
12211 {
12212 custom_subscreen[1].objects[i].d1 = 8594;
12213 custom_subscreen[1].objects[i].d2 = 8;
12214 custom_subscreen[1].objects[i].d3 = 8771;
12215 custom_subscreen[1].objects[i].d4 = 8;
12216 custom_subscreen[1].objects[i].d5 = 1;
12217 custom_subscreen[1].objects[i].d6 = 1;
12218 break;
12219 }*/
12220
12221 default:
12222 1412 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12223 1412 break;
12224 }
12225 1495 }
12226
12227 23 custom_subscreen[1].ss_type=sstACTIVE;
12228 23 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12229 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12230 23 tempsub = default_subscreen_passive[tempsubscreen][0];
12231
12232
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 23 times.
483 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12233 {
12234
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 23 times.
460 switch(tempsub[i].type)
12235 {
12236 case ssoTEXT:
12237 case ssoTEXTBOX:
12238 case ssoCURRENTITEMTEXT:
12239 case ssoCURRENTITEMCLASSTEXT:
12240
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12241
12242 69 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12243 69 custom_subscreen[2].objects[i].dp1 = NULL;
12244 69 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12245 69 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12246 69 break;
12247
12248 case ssoLIFEMETER:
12249 {
12250 23 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12251
12252
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12253 7 custom_subscreen[2].objects[i].d3=1;
12254 else
12255 16 custom_subscreen[2].objects[i].d3=0;
12256
12257 23 break;
12258 }
12259
12260 default:
12261 368 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12262 368 break;
12263 }
12264 460 }
12265
12266 23 custom_subscreen[2].ss_type=sstPASSIVE;
12267 23 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12268 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12269 23 tempsub = default_subscreen_passive[tempsubscreen][1];
12270
12271
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 23 times.
460 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12272 {
12273
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 23 times.
437 switch(tempsub[i].type)
12274 {
12275 case ssoTEXT:
12276 case ssoTEXTBOX:
12277 case ssoCURRENTITEMTEXT:
12278 case ssoCURRENTITEMCLASSTEXT:
12279
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12280
12281 69 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12282 69 custom_subscreen[3].objects[i].dp1 = NULL;
12283 69 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12284 69 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12285 69 break;
12286
12287 case ssoLIFEMETER:
12288 {
12289 23 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12290
12291
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12292 7 custom_subscreen[3].objects[i].d3=1;
12293 else
12294 16 custom_subscreen[3].objects[i].d3=0;
12295
12296 23 break;
12297 }
12298
12299 default:
12300 345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12301 345 break;
12302 }
12303 437 }
12304
12305 23 custom_subscreen[3].ss_type=sstPASSIVE;
12306 23 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12307 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12308 23 break;
12309 }
12310
12311 case ssdtZ3:
12312 {
12313 tempsub = z3_active_a;
12314 int32_t i;
12315
12316 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12317 {
12318 switch(tempsub[i].type)
12319 {
12320 case ssoTEXT:
12321 case ssoTEXTBOX:
12322 case ssoCURRENTITEMTEXT:
12323 case ssoCURRENTITEMCLASSTEXT:
12324 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12325
12326 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12327 custom_subscreen[0].objects[i].dp1 = NULL;
12328 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12329 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12330 break;
12331
12332 case ssoLIFEMETER:
12333 {
12334 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12335
12336 if(get_bit(deprecated_rules, 12) != 0)
12337 custom_subscreen[0].objects[i].d3=1;
12338 else
12339 custom_subscreen[0].objects[i].d3=0;
12340
12341 break;
12342 }
12343
12344 default:
12345 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12346 break;
12347 }
12348 }
12349
12350 custom_subscreen[0].ss_type=sstACTIVE;
12351 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12352 tempsub = z3_active_ab;
12353
12354 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12355 {
12356 switch(tempsub[i].type)
12357 {
12358 case ssoTEXT:
12359 case ssoTEXTBOX:
12360 case ssoCURRENTITEMTEXT:
12361 case ssoCURRENTITEMCLASSTEXT:
12362 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12363
12364 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12365 custom_subscreen[1].objects[i].dp1 = NULL;
12366 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12367 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12368 break;
12369
12370 case ssoLIFEMETER:
12371 {
12372 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12373
12374 if(get_bit(deprecated_rules, 12) != 0)
12375 custom_subscreen[1].objects[i].d3=1;
12376 else
12377 custom_subscreen[1].objects[i].d3=0;
12378
12379 break;
12380 }
12381
12382 default:
12383 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12384 break;
12385 }
12386 }
12387
12388 custom_subscreen[1].ss_type=sstACTIVE;
12389 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12390 tempsub = z3_passive_a;
12391
12392 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12393 {
12394 switch(tempsub[i].type)
12395 {
12396 case ssoTEXT:
12397 case ssoTEXTBOX:
12398 case ssoCURRENTITEMTEXT:
12399 case ssoCURRENTITEMCLASSTEXT:
12400 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12401
12402 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12403 custom_subscreen[2].objects[i].dp1 = NULL;
12404 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12405 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12406 break;
12407
12408 case ssoLIFEMETER:
12409 {
12410 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12411
12412 if(get_bit(deprecated_rules, 12) != 0)
12413 custom_subscreen[2].objects[i].d3=1;
12414 else
12415 custom_subscreen[2].objects[i].d3=0;
12416
12417 break;
12418 }
12419
12420 default:
12421 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12422 break;
12423 }
12424 }
12425
12426 custom_subscreen[2].ss_type=sstPASSIVE;
12427 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12428 tempsub = z3_passive_ab;
12429
12430 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12431 {
12432 switch(tempsub[i].type)
12433 {
12434 case ssoTEXT:
12435 case ssoTEXTBOX:
12436 case ssoCURRENTITEMTEXT:
12437 case ssoCURRENTITEMCLASSTEXT:
12438 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12439
12440 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12441 custom_subscreen[3].objects[i].dp1 = NULL;
12442 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12443 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12444 break;
12445
12446 case ssoLIFEMETER:
12447 {
12448 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12449
12450 if(get_bit(deprecated_rules, 12) != 0)
12451 custom_subscreen[3].objects[i].d3=1;
12452 else
12453 custom_subscreen[3].objects[i].d3=0;
12454
12455 break;
12456 }
12457
12458 default:
12459 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12460 break;
12461 }
12462 }
12463
12464 custom_subscreen[3].ss_type=sstPASSIVE;
12465 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12466 break;
12467 }
12468 }
12469
12470
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 92 times.
115 for(int32_t i=0; i<4; ++i)
12471 {
12472 92 purge_blank_subscreen_objects(&custom_subscreen[i]);
12473 92 }
12474
12475 23 return 0;
12476 }
12477
12478 extern script_data *ffscripts[NUMSCRIPTFFC];
12479 extern script_data *itemscripts[NUMSCRIPTITEM];
12480 extern script_data *guyscripts[NUMSCRIPTGUYS];
12481 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12482 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12483 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12484 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12485 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12486 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12487 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12488 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12489 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12490 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12491 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12492
12493
12494
12495 99 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12496 {
12497 int32_t dummy;
12498 99 word s_version=0, s_cversion=0, zmeta_version=0;
12499 99 byte numscripts=0;
12500 99 numscripts=numscripts; //to avoid unused variables warnings
12501 int32_t ret;
12502
12503 //section version info
12504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
12505 {
12506 return qe_invalid;
12507 }
12508
12509 99 FFCore.quest_format[vFFScript] = s_version;
12510
12511
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
12512 {
12513 return qe_invalid;
12514 }
12515
12516
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >= 18)
12517 {
12518
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&zmeta_version,f,true))
12519 {
12520 return qe_invalid;
12521 }
12522 23 }
12523
12524 //al_trace("Scripts version %d\n", s_version);
12525 //section size
12526
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
12527 {
12528 return qe_invalid;
12529 }
12530
12531 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12532 99 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12533 99 temp_ffscript_version = s_version;
12534 //miscQdata *the_misc;
12535
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12536 99 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12537
12538 //finally... section data
12539
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12540 {
12541 50688 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12542
12543
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(ret != 0) return qe_invalid;
12544 50688 }
12545
12546 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12547 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12548 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12549 * there was a version bump a week before a change that broke stuff.
12550 */
12551
6/8
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 76 times.
99 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12552 {
12553 76 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12554 76 }
12555
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
99 if(s_version < 19 && keepdata)
12556 {
12557 76 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12558 76 }
12559
12560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 1)
12561 {
12562
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12563 {
12564 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12565
12566
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12567 25344 }
12568
12569
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12570 {
12571 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12572
12573
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12574 25344 }
12575
12576
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12577 {
12578 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12579
12580
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12581 25344 }
12582
12583
12584
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12585 {
12586 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12587
12588
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12589 25344 }
12590
12591
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if(s_version > 16)
12592 {
12593
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12594 {
12595 184 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12596
12597
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(ret != 0) return qe_invalid;
12598 184 }
12599 23 }
12600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 else if(s_version > 13)
12601 {
12602 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12603 {
12604 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12605
12606 if(ret != 0) return qe_invalid;
12607 }
12608
12609 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12610 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12611
12612 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12613 }
12614
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 else if(s_version > 4)
12615 {
12616
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12617 {
12618 304 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12619
12620
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(ret != 0) return qe_invalid;
12621 304 }
12622
12623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12624
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12625
12626
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12627
12628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12629
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12630
12631
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12632
12633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12634
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_F6];
12635
12636
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12637
12638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12639
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12640
12641
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12642 76 }
12643 else
12644 {
12645 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12646 {
12647 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12648
12649 if(ret != 0) return qe_invalid;
12650 }
12651
12652 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12653 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12654
12655 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12656
12657 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12658 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12659
12660 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12661
12662 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12663 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12664
12665 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12666
12667 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12668 delete globalscripts[GLOBAL_SCRIPT_F6];
12669
12670 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12671
12672 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12673 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12674
12675 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12676 }
12677
12678
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if(s_version > 10) //expanded the number of Player scripts to 5.
12679 {
12680
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 23 times.
138 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12681 {
12682 115 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12683
12684
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(ret != 0) return qe_invalid;
12685 115 }
12686 23 }
12687 else
12688 {
12689
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 76 times.
304 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12690 {
12691 228 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12692
12693
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(ret != 0) return qe_invalid;
12694 228 }
12695
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[3] != NULL)
12696
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete playerscripts[3];
12697
12698
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[3] = new script_data();
12699
12700
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[4] != NULL)
12701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 delete playerscripts[4];
12702
12703
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[4] = new script_data();
12704 }
12705
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
99 if(s_version > 8 && s_version < 10)
12706 {
12707
12708 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12709 {
12710 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12711
12712 if(ret != 0) return qe_invalid;
12713 }
12714 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12715 {
12716 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12717
12718 if(ret != 0) return qe_invalid;
12719 }
12720
12721 }
12722
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >= 10)
12723 {
12724
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12725 {
12726 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12727
12728
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12729 5888 }
12730
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12731 {
12732 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12733
12734
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12735 5888 }
12736
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12737 {
12738 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12739
12740
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12741 5888 }
12742
12743 23 }
12744
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >=12)
12745 {
12746
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12747 {
12748 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12749
12750
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12751 5888 }
12752 23 }
12753
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >=15)
12754 {
12755
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12756 {
12757 11776 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12758
12759
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(ret != 0) return qe_invalid;
12760 11776 }
12761 23 }
12762
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >19)
12763 {
12764 23 word numgenscripts = NUMSCRIPTSGENERIC;
12765
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&numgenscripts,f,true))
12766 {
12767 return qe_invalid;
12768 }
12769
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i = 0; i < numgenscripts; i++)
12770 {
12771 11776 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12772
12773
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(ret != 0) return qe_invalid;
12774 11776 }
12775 23 }
12776
12777 /*
12778 else //Is this trip really necessary?
12779 {
12780 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12781 {
12782
12783 ewpnscripts[i] = NULL;
12784 }
12785 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12786 {
12787 dmapscripts[i] = NULL;
12788 }
12789 }
12790 */
12791
12792 99 }
12793
12794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 2)
12795 {
12796 int32_t bufsize;
12797 99 p_igetl(&bufsize, f, true);
12798 99 char * buf = new char[bufsize+1];
12799 99 pfread(buf, bufsize, f, true);
12800 99 buf[bufsize]=0;
12801
12802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
12803
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 zScript = string(buf);
12804
12805
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 delete[] buf;
12806 word numffcbindings;
12807 99 p_igetw(&numffcbindings, f, true);
12808
12809
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 99 times.
1543 for(int32_t i=0; i<numffcbindings; i++)
12810 {
12811 word id;
12812 1444 p_igetw(&id, f, true);
12813 1444 p_igetl(&bufsize, f, true);
12814 1444 buf = new char[bufsize+1];
12815 1444 pfread(buf, bufsize, f, true);
12816 1444 buf[bufsize]=0;
12817
12818 //fix for buggy older saved quests -DD
12819
2/4
✓ Branch 0 taken 1444 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1444 times.
1444 if(keepdata && id < NUMSCRIPTFFC-1)
12820 1444 ffcmap[id].scriptname = buf;
12821
12822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1444 times.
1444 delete[] buf;
12823 1444 }
12824
12825 word numglobalbindings;
12826 99 p_igetw(&numglobalbindings, f, true);
12827
12828
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 99 times.
501 for(int32_t i=0; i<numglobalbindings; i++)
12829 {
12830 word id;
12831 402 p_igetw(&id, f, true);
12832 402 p_igetl(&bufsize, f, true);
12833 402 buf = new char[bufsize+1];
12834 402 pfread(buf, bufsize, f, true);
12835 402 buf[bufsize]=0;
12836
12837 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12838 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12839 // Ignore these. -DD
12840
4/6
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 243 times.
402 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12841 {
12842 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12843
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(strcmp(buf,"~Continue") == 0)
12844 {
12845 globalmap[id].scriptname = "";
12846
12847 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12848 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12849 }
12850 else
12851 {
12852 243 globalmap[id].scriptname = buf;
12853 }
12854 243 }
12855
12856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 delete[] buf;
12857 402 }
12858
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 3)
12860 {
12861 word numitembindings;
12862 99 p_igetw(&numitembindings, f, true);
12863
12864
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 99 times.
197 for(int32_t i=0; i<numitembindings; i++)
12865 {
12866 word id;
12867 98 p_igetw(&id, f, true);
12868 98 p_igetl(&bufsize, f, true);
12869 98 buf = new char[bufsize+1];
12870 98 pfread(buf, bufsize, f, true);
12871 98 buf[bufsize]=0;
12872
12873 //fix this too
12874
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if(keepdata && id <NUMSCRIPTITEM-1)
12875 98 itemmap[id].scriptname = buf;
12876
12877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12878 98 }
12879 99 }
12880 //(v9+)
12881
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version > 8)
12882 {
12883 //npc scripts
12884 word numnpcbindings;
12885 23 p_igetw(&numnpcbindings, f, true);
12886
12887
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 23 times.
35 for(int32_t i=0; i<numnpcbindings; i++)
12888 {
12889 word id;
12890 12 p_igetw(&id, f, true);
12891 12 p_igetl(&bufsize, f, true);
12892 12 buf = new char[bufsize+1];
12893 12 pfread(buf, bufsize, f, true);
12894 12 buf[bufsize]=0;
12895
12896 //fix this too
12897
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12898 12 npcmap[id].scriptname = buf;
12899
12900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12901 12 }
12902 //lweapon
12903 word numlwpnbindings;
12904 23 p_igetw(&numlwpnbindings, f, true);
12905
12906
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 23 times.
65 for(int32_t i=0; i<numlwpnbindings; i++)
12907 {
12908 word id;
12909 42 p_igetw(&id, f, true);
12910 42 p_igetl(&bufsize, f, true);
12911 42 buf = new char[bufsize+1];
12912 42 pfread(buf, bufsize, f, true);
12913 42 buf[bufsize]=0;
12914
12915 //fix this too
12916
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12917 42 lwpnmap[id].scriptname = buf;
12918
12919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12920 42 }
12921 //eweapon
12922 word numewpnbindings;
12923 23 p_igetw(&numewpnbindings, f, true);
12924
12925
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 23 times.
86 for(int32_t i=0; i<numewpnbindings; i++)
12926 {
12927 word id;
12928 63 p_igetw(&id, f, true);
12929 63 p_igetl(&bufsize, f, true);
12930 63 buf = new char[bufsize+1];
12931 63 pfread(buf, bufsize, f, true);
12932 63 buf[bufsize]=0;
12933
12934 //fix this too
12935
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12936 63 ewpnmap[id].scriptname = buf;
12937
12938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12939 63 }
12940 //hero
12941 word numherobindings;
12942 23 p_igetw(&numherobindings, f, true);
12943
12944
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23 times.
27 for(int32_t i=0; i<numherobindings; i++)
12945 {
12946 word id;
12947 4 p_igetw(&id, f, true);
12948 4 p_igetl(&bufsize, f, true);
12949 4 buf = new char[bufsize+1];
12950 4 pfread(buf, bufsize, f, true);
12951 4 buf[bufsize]=0;
12952
12953 //fix this too
12954
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12955 4 playermap[id].scriptname = buf;
12956
12957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12958 4 }
12959 //dmaps
12960 word numdmapbindings;
12961 23 p_igetw(&numdmapbindings, f, true);
12962
12963
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 23 times.
37 for(int32_t i=0; i<numdmapbindings; i++)
12964 {
12965 word id;
12966 14 p_igetw(&id, f, true);
12967 14 p_igetl(&bufsize, f, true);
12968 14 buf = new char[bufsize+1];
12969 14 pfread(buf, bufsize, f, true);
12970 14 buf[bufsize]=0;
12971
12972 //fix this too
12973
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12974 14 dmapmap[id].scriptname = buf;
12975
12976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12977 14 }
12978 //screen
12979 word numscreenbindings;
12980 23 p_igetw(&numscreenbindings, f, true);
12981
12982
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 23 times.
34 for(int32_t i=0; i<numscreenbindings; i++)
12983 {
12984 word id;
12985 11 p_igetw(&id, f, true);
12986 11 p_igetl(&bufsize, f, true);
12987 11 buf = new char[bufsize+1];
12988 11 pfread(buf, bufsize, f, true);
12989 11 buf[bufsize]=0;
12990
12991 //fix this too
12992
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12993 11 screenmap[id].scriptname = buf;
12994
12995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12996 11 }
12997 23 }
12998
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version > 11)
12999 {
13000 word numspritebindings;
13001 23 p_igetw(&numspritebindings, f, true);
13002
13003
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 for(int32_t i=0; i<numspritebindings; i++)
13004 {
13005 word id;
13006 10 p_igetw(&id, f, true);
13007 10 p_igetl(&bufsize, f, true);
13008 10 buf = new char[bufsize+1];
13009 10 pfread(buf, bufsize, f, true);
13010 10 buf[bufsize]=0;
13011
13012 //fix this too
13013
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
13014 10 itemspritemap[id].scriptname = buf;
13015
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
13017 10 }
13018 23 }
13019
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version >= 15)
13020 {
13021 word numcombobindings;
13022 23 p_igetw(&numcombobindings, f, true);
13023
13024
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 23 times.
47 for(int32_t i=0; i<numcombobindings; i++)
13025 {
13026 word id;
13027 24 p_igetw(&id, f, true);
13028 24 p_igetl(&bufsize, f, true);
13029 24 buf = new char[bufsize+1];
13030 24 pfread(buf, bufsize, f, true);
13031 24 buf[bufsize]=0;
13032
13033 //fix this too
13034
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
13035 24 comboscriptmap[id].scriptname = buf;
13036
13037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
13038 24 }
13039 23 }
13040
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 23 times.
99 if(s_version > 19)
13041 {
13042 word numgenericbindings;
13043 23 p_igetw(&numgenericbindings, f, true);
13044
13045
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 23 times.
37 for(int32_t i=0; i<numgenericbindings; i++)
13046 {
13047 word id;
13048 14 p_igetw(&id, f, true);
13049 14 p_igetl(&bufsize, f, true);
13050 14 buf = new char[bufsize+1];
13051 14 pfread(buf, bufsize, f, true);
13052 14 buf[bufsize]=0;
13053
13054 //fix this too
13055
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13056 14 genericmap[id].scriptname = buf;
13057
13058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
13059 14 }
13060 23 }
13061 99 }
13062
13063 99 return 0;
13064 99 }
13065
13066 108 void reset_scripts()
13067 {
13068 //OK, who spaced this? ;)
13069
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13070 {
13071
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55296 times.
55296 if(ffscripts[i]!=NULL) delete ffscripts[i];
13072 55296 }
13073
13074
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13075 {
13076
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(itemscripts[i]!=NULL) delete itemscripts[i];
13077 27648 }
13078
13079
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13080 {
13081
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(guyscripts[i]!=NULL) delete guyscripts[i];
13082 27648 }
13083
13084
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13085 {
13086
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13087 27648 }
13088
13089
13090
13091
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13092 {
13093
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(screenscripts[i]!=NULL) delete screenscripts[i];
13094 27648 }
13095
13096
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13097 {
13098
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 if(globalscripts[i]!=NULL) delete globalscripts[i];
13099 864 }
13100
13101
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 108 times.
648 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13102 {
13103
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 540 times.
540 if(playerscripts[i]!=NULL) delete playerscripts[i];
13104 540 }
13105
13106
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13107 {
13108
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13109 27648 }
13110
13111
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13112 {
13113
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13114 27648 }
13115
13116
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13117 {
13118
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13119 27648 }
13120
13121
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13122 {
13123
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13124 27648 }
13125
13126
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13127 {
13128
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55296 times.
55296 if(comboscripts[i]!=NULL) delete comboscripts[i];
13129 55296 }
13130
13131 108 next_script_data_debug_id = 0;
13132
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13133 {
13134
3/4
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 38400 times.
✓ Branch 2 taken 38400 times.
✗ Branch 3 not taken.
55296 if(genericscripts[i]!=NULL) delete genericscripts[i];
13135
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 genericscripts[i] = new script_data();
13136 55296 }
13137
13138
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13139 {
13140
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 ffscripts[i] = new script_data();
13141 55296 }
13142
13143
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13144 {
13145
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 itemscripts[i] = new script_data();
13146 27648 }
13147
13148
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13149 {
13150
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 guyscripts[i] = new script_data();
13151 27648 }
13152
13153
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13154 {
13155
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 wpnscripts[i] = new script_data();
13156 27648 }
13157
13158
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13159 {
13160
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 screenscripts[i] = new script_data();
13161 27648 }
13162
13163
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13164 {
13165
1/2
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
864 globalscripts[i] = new script_data();
13166 864 }
13167
13168
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 108 times.
648 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13169 {
13170
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 playerscripts[i] = new script_data();
13171 540 }
13172
13173
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13174 {
13175
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 lwpnscripts[i] = new script_data();
13176 27648 }
13177
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13178 {
13179
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 ewpnscripts[i] = new script_data();
13180 27648 }
13181
13182
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13183 {
13184
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 dmapscripts[i] = new script_data();
13185 27648 }
13186
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13187 {
13188
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 itemspritescripts[i] = new script_data();
13189 27648 }
13190
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13191 {
13192
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 comboscripts[i] = new script_data();
13193 55296 }
13194 108 }
13195
13196 extern script_command command_list[];
13197 199999 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13198 {
13199 //Please also update loadquest() when modifying this method -DD
13200 199999 char b33[34] = {0};
13201 199999 b33[33] = 0;
13202 199999 ffscript temp_script;
13203 199999 int32_t num_commands=1000;
13204
13205
1/2
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
199999 if(s_version>=2)
13206 {
13207
2/4
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 199999 times.
✗ Branch 3 not taken.
199999 if(!p_igetl(&num_commands,f,true))
13208 {
13209 return qe_invalid;
13210 }
13211 199999 }
13212
13213
1/2
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
199999 if(keepdata)
13214 {
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199999 times.
199999 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199999 times.
199999 delete (*script);
13217
2/4
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 199999 times.
✗ Branch 3 not taken.
199999 (*script) = new script_data(num_commands);
13218 199999 }
13219
2/2
✓ Branch 0 taken 82731 times.
✓ Branch 1 taken 117268 times.
199999 if(s_version >= 16)
13220 {
13221
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 zasm_meta temp_meta;
13222
13223
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13224 {
13225 return qe_invalid;
13226 }
13227
13228
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.meta_v),f,true))
13229 {
13230 return qe_invalid;
13231 }
13232
13233
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13234 {
13235 return qe_invalid;
13236 }
13237
13238
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getc(&(temp_meta.script_type),f,true))
13239 {
13240 return qe_invalid;
13241 }
13242
13243
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(int32_t q = 0; q < 8; ++q)
13244 {
13245
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 604296 times.
661848 if(zmeta_version < 3)
13246 {
13247
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13248 {
13249
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13250 {
13251 return qe_invalid;
13252 }
13253 1899216 }
13254
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13255 57552 }
13256 else
13257 {
13258
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13259 {
13260 return qe_invalid;
13261 }
13262 }
13263 661848 }
13264
13265
2/2
✓ Branch 0 taken 82731 times.
✓ Branch 1 taken 661848 times.
744579 for(int32_t q = 0; q < 8; ++q)
13266 {
13267
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13268 {
13269 return qe_invalid;
13270 }
13271 661848 }
13272
13273
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getc(&(temp_meta.flags),f,true))
13274 {
13275 return qe_invalid;
13276 }
13277
13278
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13279 {
13280 return qe_invalid;
13281 }
13282
13283
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13284 {
13285 return qe_invalid;
13286 }
13287
13288
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13289 {
13290 return qe_invalid;
13291 }
13292
13293
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13294 {
13295 return qe_invalid;
13296 }
13297
13298
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 75537 times.
82731 if(zmeta_version == 2)
13299 {
13300
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13301 {
13302
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13303 {
13304 return qe_invalid;
13305 }
13306 237402 }
13307
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13308
13309
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13310 {
13311
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13312 {
13313 return qe_invalid;
13314 }
13315 237402 }
13316
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13317 7194 }
13318
1/2
✓ Branch 0 taken 75537 times.
✗ Branch 1 not taken.
75537 else if(zmeta_version > 2)
13319 {
13320
2/4
✓ Branch 0 taken 75537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75537 times.
✗ Branch 3 not taken.
75537 if(!p_getcstr(&temp_meta.script_name,f,true))
13321 return qe_invalid;
13322
2/4
✓ Branch 0 taken 75537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75537 times.
✗ Branch 3 not taken.
75537 if(!p_getcstr(&temp_meta.author,f,true))
13323 return qe_invalid;
13324 75537 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13325
2/2
✓ Branch 0 taken 755370 times.
✓ Branch 1 taken 75537 times.
830907 for(auto q = 0; q < num_meta_attrib; ++q)
13326 {
13327
2/4
✓ Branch 0 taken 755370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755370 times.
✗ Branch 3 not taken.
755370 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13328 return qe_invalid;
13329
2/4
✓ Branch 0 taken 755370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755370 times.
✗ Branch 3 not taken.
755370 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13330 return qe_invalid;
13331 755370 }
13332
2/2
✓ Branch 0 taken 604296 times.
✓ Branch 1 taken 75537 times.
679833 for(auto q = 0; q < 8; ++q)
13333 {
13334
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13335 return qe_invalid;
13336
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13337 return qe_invalid;
13338 604296 }
13339
2/2
✓ Branch 0 taken 604296 times.
✓ Branch 1 taken 75537 times.
679833 for(auto q = 0; q < 8; ++q)
13340 {
13341
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13342 return qe_invalid;
13343
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13344 return qe_invalid;
13345 604296 }
13346
2/2
✓ Branch 0 taken 1208592 times.
✓ Branch 1 taken 75537 times.
1284129 for(auto q = 0; q < 16; ++q)
13347 {
13348
2/4
✓ Branch 0 taken 1208592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1208592 times.
✗ Branch 3 not taken.
1208592 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13349 return qe_invalid;
13350
2/4
✓ Branch 0 taken 1208592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1208592 times.
✗ Branch 3 not taken.
1208592 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13351 return qe_invalid;
13352 1208592 }
13353 75537 }
13354
2/2
✓ Branch 0 taken 75537 times.
✓ Branch 1 taken 7194 times.
82731 if(zmeta_version > 3)
13355 {
13356
2/2
✓ Branch 0 taken 604296 times.
✓ Branch 1 taken 75537 times.
679833 for(auto q = 0; q < 8; ++q)
13357 {
13358
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getcstr(&temp_meta.initd[q],f,true))
13359 return qe_invalid;
13360
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13361 return qe_invalid;
13362 604296 }
13363
2/2
✓ Branch 0 taken 604296 times.
✓ Branch 1 taken 75537 times.
679833 for(auto q = 0; q < 8; ++q)
13364 {
13365
2/4
✓ Branch 0 taken 604296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604296 times.
✗ Branch 3 not taken.
604296 if(!p_getc(&temp_meta.initd_type[q],f,true))
13366 return qe_invalid;
13367 604296 }
13368 75537 }
13369 else
13370 {
13371
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13372 {
13373
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13374 57552 }
13375 }
13376
13377
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 if(keepdata)
13378
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 (*script)->meta = temp_meta;
13379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82731 times.
82731 }
13380
13381
1/2
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
199999 temp_script.clear();
13382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21306572 times.
21306572 for(int32_t j=0; j<num_commands; j++)
13383 {
13384
2/4
✓ Branch 0 taken 21306572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21306572 times.
✗ Branch 3 not taken.
21306572 if(!p_igetw(&(temp_script.command),f,true))
13385 {
13386 return qe_invalid;
13387 }
13388
13389
2/2
✓ Branch 0 taken 21106573 times.
✓ Branch 1 taken 199999 times.
21306572 if(temp_script.command == 0xFFFF)
13390 {
13391
1/2
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
199999 if(keepdata)
13392
1/2
✓ Branch 0 taken 199999 times.
✗ Branch 1 not taken.
199999 (*script)->zasm[j].clear();
13393 199999 break;
13394 }
13395 else
13396 {
13397
2/4
✓ Branch 0 taken 21106573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21106573 times.
✗ Branch 3 not taken.
21106573 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13398 {
13399 return qe_invalid;
13400 }
13401
13402
2/4
✓ Branch 0 taken 21106573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21106573 times.
✗ Branch 3 not taken.
21106573 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13403 {
13404 return qe_invalid;
13405 }
13406
13407
2/2
✓ Branch 0 taken 434778 times.
✓ Branch 1 taken 20671795 times.
21106573 if(s_version >= 21)
13408 {
13409 434778 uint32_t sz = 0;
13410
2/4
✓ Branch 0 taken 434778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 434778 times.
✗ Branch 3 not taken.
434778 if(!p_igetl(&sz,f,keepdata))
13411 {
13412 return qe_invalid;
13413 }
13414
2/2
✓ Branch 0 taken 1513 times.
✓ Branch 1 taken 433265 times.
434778 if(sz) //string found
13415 {
13416
1/2
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
1513 temp_script.strptr = new std::string();
13417 char dummy;
13418
2/2
✓ Branch 0 taken 114807 times.
✓ Branch 1 taken 1513 times.
116320 for(size_t q = 0; q < sz; ++q)
13419 {
13420
2/4
✓ Branch 0 taken 114807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114807 times.
✗ Branch 3 not taken.
114807 if(!p_getc(&dummy,f,keepdata))
13421 {
13422 return qe_invalid;
13423 }
13424
1/2
✓ Branch 0 taken 114807 times.
✗ Branch 1 not taken.
114807 temp_script.strptr->push_back(dummy);
13425 114807 }
13426 1513 }
13427
2/4
✓ Branch 0 taken 434778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 434778 times.
✗ Branch 3 not taken.
434778 if(!p_igetl(&sz,f,keepdata))
13428 {
13429 return qe_invalid;
13430 }
13431
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 434688 times.
434778 if(sz) //vector found
13432 {
13433
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13434 int32_t dummy;
13435
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13436 {
13437
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13438 {
13439 return qe_invalid;
13440 }
13441
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13442 1311 }
13443 90 }
13444 434778 }
13445
13446
1/2
✓ Branch 0 taken 21106573 times.
✗ Branch 1 not taken.
21106573 if(keepdata)
13447 {
13448
1/2
✓ Branch 0 taken 21106573 times.
✗ Branch 1 not taken.
21106573 temp_script.give((*script)->zasm[j]);
13449 21106573 }
13450 }
13451
1/2
✓ Branch 0 taken 21106573 times.
✗ Branch 1 not taken.
21106573 temp_script.clear();
13452 21106573 }
13453
13454 199999 return 0;
13455 199999 }
13456
13457 extern SAMPLE customsfxdata[WAV_COUNT];
13458 extern uint8_t customsfxflag[WAV_COUNT>>3];
13459 extern int32_t sfxdat;
13460 extern DATAFILE *sfxdata;
13461 const char *old_sfx_string[Z35] =
13462 {
13463 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13464 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13465 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13466 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13467 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13468 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13469 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13470 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13471 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13472 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13473 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13474 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13475 };
13476 char *sfx_string[WAV_COUNT];
13477
13478 99 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13479 {
13480 //these are here to bypass compiler warnings about unused arguments
13481 99 Header=Header;
13482
13483 int32_t dummy;
13484 99 word s_version=0, s_cversion=0;
13485 //int32_t ret;
13486 SAMPLE temp_sample;
13487 99 temp_sample.loop_start=0;
13488 99 temp_sample.loop_end=0;
13489 99 temp_sample.param=0;
13490
13491 //section version info
13492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
13493 {
13494 return qe_invalid;
13495 }
13496
13497 99 FFCore.quest_format[vSFX] = s_version;
13498
13499 //al_trace("SFX version %d\n", s_version);
13500
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
13501 {
13502 return qe_invalid;
13503 }
13504
13505 //section size
13506
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
13507 {
13508 return qe_invalid;
13509 }
13510
13511 /* HIGHLY UNORTHODOX UPDATING THING, by L
13512 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13513 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13514 * changing from 1 to 2.
13515 */
13516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(s_version < 2 && keepdata)
13517 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13518
13519 /* End highly unorthodox updating thing */
13520
13521 99 int32_t wavcount = WAV_COUNT;
13522
13523
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version < 6)
13524 wavcount = 128;
13525
13526 uint8_t tempflag[WAV_COUNT>>3];
13527
13528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version < 4)
13529 {
13530 memset(tempflag, 0xFF, WAV_COUNT>>3);
13531 }
13532 else
13533 {
13534
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version < 6)
13535 memset(tempflag, 0, WAV_COUNT>>3);
13536
13537
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 99 times.
3267 for(int32_t i=0; i<(wavcount>>3); i++)
13538 {
13539 3168 p_getc(&tempflag[i], f, true);
13540 3168 }
13541
13542 }
13543
13544
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version>4)
13545 {
13546
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<WAV_COUNT; i++)
13547 {
13548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25245 times.
25245 if(keepdata)
13549 {
13550 25245 sprintf(sfx_string[i],"s%03d",i);
13551
13552
2/2
✓ Branch 0 taken 19305 times.
✓ Branch 1 taken 5940 times.
25245 if((i<Z35))
13553 5940 strcpy(sfx_string[i], old_sfx_string[i-1]);
13554 25245 }
13555
13556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25245 times.
25245 if(i>=wavcount)
13557 continue;
13558
2/2
✓ Branch 0 taken 2077 times.
✓ Branch 1 taken 23168 times.
25245 if(get_bit(tempflag, i-1))
13559 {
13560 char tempname[36];
13561
13562
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!pfread(tempname, 36, f, keepdata))
13563 {
13564 return qe_invalid;
13565 }
13566
13567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2077 times.
2077 if(keepdata)
13568 {
13569 2077 strcpy(sfx_string[i], tempname);
13570 2077 sfx_string[i][35] = 0; //Force NULL Termination
13571 2077 }
13572 2077 }
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23168 times.
23168 else if(keepdata)
13574 {
13575 23168 sprintf(sfx_string[i],"s%03d",i);
13576
13577
2/2
✓ Branch 0 taken 18650 times.
✓ Branch 1 taken 4518 times.
23168 if(i<Z35)
13578 4518 strcpy(sfx_string[i], old_sfx_string[i-1]);
13579 23168 sfx_string[i][35] = 0; //Force NULL Termination
13580 23168 }
13581 25245 }
13582 99 }
13583 else
13584 {
13585 if(keepdata)
13586 {
13587 for(int32_t i=1; i<WAV_COUNT; i++)
13588 {
13589 sprintf(sfx_string[i],"s%03d",i);
13590
13591 if(i<Z35)
13592 strcpy(sfx_string[i], old_sfx_string[i-1]);
13593 }
13594 }
13595 }
13596
13597 //finally... section data
13598
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<wavcount; i++)
13599 {
13600
2/2
✓ Branch 0 taken 2077 times.
✓ Branch 1 taken 23168 times.
25245 if(get_bit(tempflag, i-1))
13601 {
13602
13603
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&dummy,f,true))
13604 {
13605 return qe_invalid;
13606 }
13607
13608 2077 (temp_sample.bits) = dummy;
13609
13610
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&dummy,f,true))
13611 {
13612 return qe_invalid;
13613 }
13614
13615 2077 (temp_sample.stereo) = dummy;
13616
13617
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&dummy,f,keepdata))
13618 {
13619 return qe_invalid;
13620 }
13621
13622 2077 (temp_sample.freq) = dummy;
13623
13624
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&dummy,f,keepdata))
13625 {
13626 return qe_invalid;
13627 }
13628
13629 2077 (temp_sample.priority) = dummy;
13630
13631
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&(temp_sample.len),f,true))
13632 {
13633 return qe_invalid;
13634 }
13635
13636
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13637 {
13638 return qe_invalid;
13639 }
13640
13641
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13642 {
13643 return qe_invalid;
13644 }
13645
13646
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(!p_igetl(&(temp_sample.param),f,keepdata))
13647 {
13648 return qe_invalid;
13649 }
13650
13651 // al_trace("F%i: L%i\n",i,temp_sample.len);
13652 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13653 2077 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13654 2077 temp_sample.data = calloc(len,1);
13655
13656
1/2
✓ Branch 0 taken 2077 times.
✗ Branch 1 not taken.
2077 if(s_version < 3)
13657 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13658
13659 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2077 times.
2077 if(s_version < 2)
13661 {
13662 if(!pfread(temp_sample.data, len,f,keepdata))
13663 {
13664 return qe_invalid;
13665 }
13666 }
13667 else
13668 {
13669 //re-endianfy the data
13670 2077 int32_t wordstoread = len / sizeof(word);
13671
13672
2/2
✓ Branch 0 taken 64930657 times.
✓ Branch 1 taken 2077 times.
64932734 for(int32_t j=0; j<wordstoread; j++)
13673 {
13674 word temp;
13675
13676
1/2
✓ Branch 0 taken 64930657 times.
✗ Branch 1 not taken.
64930657 if(!p_igetw(&temp, f, keepdata))
13677 {
13678 return qe_invalid;
13679 }
13680
13681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64930657 times.
64930657 if(keepdata)
13682 64930657 ((word *)temp_sample.data)[j] = temp;
13683 64930657 }
13684 }
13685 2077 }
13686
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 18650 times.
23168 else if(i < Z35)
13687 {
13688 4518 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13689 4518 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13690 4518 set_bit(tempflag, i-1, 1);
13691 4518 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13692 4518 temp_sample.data = calloc(len,1);
13693 4518 memcpy(temp_sample.data, datsamp->data, len);
13694 4518 }
13695 18650 else continue;
13696
13697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6595 times.
6595 if(keepdata)
13698 {
13699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6595 times.
6595 if(customsfxdata[i].data!=NULL)
13700 {
13701 // delete [] customsfxdata[i].data;
13702 6595 free(customsfxdata[i].data);
13703 6595 }
13704
13705 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13706 6595 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13707 6595 customsfxdata[i].data = calloc(len2,1);
13708 6595 customsfxdata[i].bits = temp_sample.bits;
13709 6595 customsfxdata[i].stereo = temp_sample.stereo;
13710 6595 customsfxdata[i].freq = temp_sample.freq;
13711 6595 customsfxdata[i].priority = temp_sample.priority;
13712 6595 customsfxdata[i].len = temp_sample.len;
13713 6595 customsfxdata[i].loop_start = temp_sample.loop_start;
13714 6595 customsfxdata[i].loop_end = temp_sample.loop_end;
13715 6595 customsfxdata[i].param = temp_sample.param;
13716 6595 int32_t cpylen = len2;
13717
13718
1/2
✓ Branch 0 taken 6595 times.
✗ Branch 1 not taken.
6595 if(s_version<3)
13719 {
13720 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13721 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13722 }
13723
13724 6595 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13725 6595 }
13726
13727 6595 free(temp_sample.data);
13728 6595 }
13729
13730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
13731 99 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13732
13733 99 sfxdat=0;
13734 99 return 0;
13735 99 }
13736
13737 108 void setupsfx()
13738 {
13739
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=1; i<WAV_COUNT; i++)
13740 {
13741 27540 sprintf(sfx_string[i],"s%03d",i);
13742
13743
2/2
✓ Branch 0 taken 21060 times.
✓ Branch 1 taken 6480 times.
27540 if(i<Z35)
13744 {
13745 6480 strcpy(sfx_string[i], old_sfx_string[i-1]);
13746 6480 }
13747
13748 27540 memset(customsfxflag, 0, WAV_COUNT>>3);
13749
13750 27540 int32_t j=i;
13751
13752
2/2
✓ Branch 0 taken 6588 times.
✓ Branch 1 taken 20952 times.
27540 if(i>Z35)
13753 {
13754 20952 i=Z35;
13755 20952 }
13756
13757 27540 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13758
13759
2/2
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 19125 times.
27540 if(customsfxdata[j].data!=NULL)
13760 {
13761 // delete [] customsfxdata[j].data;
13762 19125 free(customsfxdata[j].data);
13763 19125 }
13764
13765 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13766 27540 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13767 27540 customsfxdata[j].bits = temp_sample->bits;
13768 27540 customsfxdata[j].stereo = temp_sample->stereo;
13769 27540 customsfxdata[j].freq = temp_sample->freq;
13770 27540 customsfxdata[j].priority = temp_sample->priority;
13771 27540 customsfxdata[j].len = temp_sample->len;
13772 27540 customsfxdata[j].loop_start = temp_sample->loop_start;
13773 27540 customsfxdata[j].loop_end = temp_sample->loop_end;
13774 27540 customsfxdata[j].param = temp_sample->param;
13775 27540 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13776 27540 i=j;
13777 27540 }
13778 108 }
13779
13780 extern char *guy_string[eMAXGUYS];
13781 extern const char *old_guy_string[OLDMAXGUYS];
13782
13783 108 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13784 {
13785 dword dummy;
13786 word guy_cversion;
13787 108 word guyversion=0;
13788
13789
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version >= 0x193)
13790 {
13791 //section version info
13792
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&guyversion,f,true))
13793 {
13794 return qe_invalid;
13795 }
13796
13797 104 FFCore.quest_format[vGuys] = guyversion;
13798
13799 //al_trace("Guys version %d\n", guyversion);
13800
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&guy_cversion,f,true))
13801 {
13802 return qe_invalid;
13803 }
13804 104 al_trace("Guy CVersion is: %d\n", guy_cversion);
13805 //section size
13806
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
13807 {
13808 return qe_invalid;
13809 }
13810 104 }
13811
13812
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(guyversion > 3)
13813 {
13814
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
13815 {
13816 char tempname[64];
13817
13818 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13819 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13820
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50688 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13821 {
13822 memset(tempname, 0, sizeof(char)*64);
13823 sprintf(tempname, "e%03d", i);
13824 strcpy(guy_string[i], tempname);
13825
13826 continue;
13827 }
13828
13829
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!pfread(tempname, 64, f, keepdata))
13830 {
13831 return qe_invalid;
13832 }
13833
13834 // Don't retain names of uneditable enemy entries!
13835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(keepdata)
13836 {
13837 // for version upgrade to 2.5
13838
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50688 if(guyversion < 23 && i >= 177)
13839 {
13840 // some of the older builds have names such as 'zz123',
13841 // (this order gets messed up with some eXXX and some zzXXX)
13842 // so let's update to the newer naming convection. -Gleeok
13843 char tmpbuf[64];
13844 memset(tmpbuf, 0, sizeof(char)*64);
13845 sprintf(tmpbuf, "zz%03d", i);
13846
13847 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13848 {
13849 memset(tempname, 0, sizeof(char)*64);
13850 sprintf(tempname, "e%03d", i);
13851 }
13852 }
13853
13854
6/6
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 33165 times.
✓ Branch 2 taken 16632 times.
✓ Branch 3 taken 891 times.
✓ Branch 4 taken 13705 times.
✓ Branch 5 taken 2927 times.
50688 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13855 {
13856 47761 strcpy(guy_string[i], tempname);
13857 47761 }
13858 else
13859 {
13860 2927 strcpy(guy_string[i],old_guy_string[i]);
13861 }
13862 50688 }
13863 50688 }
13864 99 }
13865 else
13866 {
13867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13868 {
13869
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13870 {
13871 4608 sprintf(guy_string[i],"zz%03d",i);
13872 4608 }
13873
13874
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13875 {
13876 1593 strcpy(guy_string[i],old_guy_string[i]);
13877 1593 }
13878 9 }
13879 }
13880
13881
13882 //finally... section data
13883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
13884 {
13885 108 init_guys(guyversion); //using default data for now...
13886
13887 // Goriya guy fix
13888
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13889 {
13890
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13891 {
13892 5 guysbuf[gGORIYA].tile=130;
13893 5 guysbuf[gGORIYA].e_tile=130;
13894 5 }
13895 9 }
13896 108 }
13897
13898
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version < 0x193)
13899 {
13900
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13901 {
13902 guysbuf[eDODONGO].cset=14;
13903 guysbuf[eDODONGO].bosspal=spDIG;
13904 }
13905 4 }
13906 // Not sure when this first changed, but it's necessary for 2.10, at least
13907 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13908 //2.10 Fixes
13909
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13910 {
13911 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13912 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13913 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13914 9 guysbuf[eCENT1].misc3 = 1;
13915 9 guysbuf[eCENT2].misc3 = 1;
13916 9 }
13917
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13918 {
13919 108 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13920 108 }
13921
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(Header->zelda_version <= 0x210)
13922 {
13923 9 guysbuf[eGLEEOK1F].misc6 = 16;
13924 9 guysbuf[eGLEEOK2F].misc6 = 16;
13925 9 guysbuf[eGLEEOK3F].misc6 = 16;
13926 9 guysbuf[eGLEEOK4F].misc6 = 16;
13927
13928 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13929 9 guysbuf[eBATROBE].misc4 = 1;
13930 //guysbuf[eSUMMONER].misc4 = 1;
13931 9 guysbuf[eWWIZ].misc4 = 1;
13932 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13933 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13934 9 }
13935
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version == 0x190)
13936 {
13937 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13938 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13939 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13940 4 }
13941
13942 // The versions here may not be correct
13943 // zelda_version>=0x211 handled at guyversion<24
13944
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version <= 0x190)
13945 {
13946 4 guysbuf[eCENT1].misc3 = 0;
13947 4 guysbuf[eCENT2].misc3 = 0;
13948 4 guysbuf[eMOLDORM].misc2 = 0;
13949 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13950 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13951 4 }
13952
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 else if(Header->zelda_version <= 0x210)
13953 {
13954 5 guysbuf[eCENT1].misc3 = 1;
13955 5 guysbuf[eCENT2].misc3 = 1;
13956 5 guysbuf[eMOLDORM].misc2 = 0;
13957 5 }
13958
13959
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13960 {
13961 9 guysbuf[eKEESE1].misc16 = 120;
13962 9 guysbuf[eKEESE2].misc16 = 120;
13963 9 guysbuf[eKEESE3].misc16 = 120;
13964 9 guysbuf[eKEESETRIB].misc16 = 120;
13965 9 guysbuf[eKEESE1].misc17 = 16;
13966 9 guysbuf[eKEESE2].misc17 = 16;
13967 9 guysbuf[eKEESE3].misc17 = 16;
13968 9 guysbuf[eKEESETRIB].misc17 = 16;
13969
13970 9 guysbuf[ePEAHAT].misc16 = 80;
13971 9 guysbuf[ePEAHAT].misc17 = 16;
13972
13973 9 guysbuf[eGHINI2].misc16 = 120;
13974 9 guysbuf[eGHINI2].misc17 = 10;
13975
13976 9 }
13977
13978
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(guyversion<=2)
13979 {
13980 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13981 }
13982
13983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(guyversion > 3)
13984 {
13985 guydata tempguy;
13986
13987
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
13988 {
13989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50688 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13990 {
13991 if(i >= OLDBETAMAXGUYS)
13992 {
13993 memset(&guysbuf[i], 0, sizeof(guydata));
13994 continue;
13995 }
13996 }
13997
13998 50688 memset(&tempguy, 0, sizeof(guydata));
13999
14000
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.flags),f,keepdata))
14001 {
14002 return qe_invalid;
14003 }
14004
14005
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.flags2),f,keepdata))
14006 {
14007 return qe_invalid;
14008 }
14009
14010
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion >= 36 ) //expanded tiles
14011 {
14012
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.tile),f,keepdata))
14013 {
14014 return qe_invalid;
14015 }
14016 11776 }
14017 else
14018 {
14019
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.tile),f,keepdata))
14020 {
14021 return qe_invalid;
14022 }
14023 }
14024
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.width),f,keepdata))
14025 {
14026 return qe_invalid;
14027 }
14028
14029
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.height),f,keepdata))
14030 {
14031 return qe_invalid;
14032 }
14033
14034
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion >= 36 ) //expanded tiles
14035 {
14036
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
14037 {
14038 return qe_invalid;
14039 }
14040 11776 }
14041 else
14042 {
14043
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14044 {
14045 return qe_invalid;
14046 }
14047 }
14048
14049
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.s_width),f,keepdata))
14050 {
14051 return qe_invalid;
14052 }
14053
14054
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.s_height),f,keepdata))
14055 {
14056 return qe_invalid;
14057 }
14058
14059
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion >= 36 ) //expanded tiles
14060 {
14061
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14062 {
14063 return qe_invalid;
14064 }
14065 11776 }
14066 else
14067 {
14068
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14069 {
14070 return qe_invalid;
14071 }
14072 }
14073
14074
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.e_width),f,keepdata))
14075 {
14076 return qe_invalid;
14077 }
14078
14079
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.e_height),f,keepdata))
14080 {
14081 return qe_invalid;
14082 }
14083
14084
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.hp),f,keepdata))
14085 {
14086 return qe_invalid;
14087 }
14088
14089
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.family),f,keepdata))
14090 {
14091 return qe_invalid;
14092 }
14093
14094
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
50688 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14095 {
14096 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14097 {
14098 tempguy.s_tile=tempguy.e_tile+120;
14099 tempguy.s_width=tempguy.e_width;
14100 tempguy.s_height=tempguy.e_height;
14101 }
14102 else tempguy.s_tile=860;
14103 }
14104
14105
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.cset),f,keepdata))
14106 {
14107 return qe_invalid;
14108 }
14109
14110
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.anim),f,keepdata))
14111 {
14112 return qe_invalid;
14113 }
14114
14115
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14116 {
14117 return qe_invalid;
14118 }
14119
14120
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.frate),f,keepdata))
14121 {
14122 return qe_invalid;
14123 }
14124
14125
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14126 {
14127 return qe_invalid;
14128 }
14129
14130
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 13) // April 2009
14131 {
14132 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14133 {
14134 tempguy.frate *= 2;
14135 tempguy.e_frate *= 2;
14136 }
14137 }
14138
14139
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 14) // May 1 2009
14140 {
14141 if(tempguy.anim==a2FRMSLOW)
14142 {
14143 tempguy.anim=a2FRM;
14144 tempguy.frate *= 2;
14145 }
14146
14147 if(tempguy.e_anim==a2FRMSLOW)
14148 {
14149 tempguy.e_anim=a2FRM;
14150 tempguy.e_frate *= 2;
14151 }
14152
14153 if(tempguy.anim==aFLIPSLOW)
14154 {
14155 tempguy.anim=aFLIP;
14156 tempguy.frate *= 2;
14157 }
14158
14159 if(tempguy.e_anim==aFLIPSLOW)
14160 {
14161 tempguy.e_anim=aFLIP;
14162 tempguy.e_frate *= 2;
14163 }
14164
14165 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14166
14167 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14168
14169 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14170 {
14171 tempguy.anim=a4FRM4DIR;
14172 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14173 }
14174
14175 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14176 {
14177 tempguy.e_anim=a4FRM4DIR;
14178 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14179 }
14180 }
14181
14182
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.dp),f,keepdata))
14183 {
14184 return qe_invalid;
14185 }
14186
14187 //correction for guy fire
14188
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 6)
14189 {
14190 if(i == gFIRE)
14191 tempguy.dp = 2;
14192 }
14193
14194
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14195 {
14196 return qe_invalid;
14197 }
14198
14199
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14200 {
14201 return qe_invalid;
14202 }
14203
14204 //correction for bosses using triple, "rising" fireballs
14205
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 5)
14206 {
14207 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14208 i == eGOHMA3 || i == eGOHMA4)
14209 {
14210 if(tempguy.weapon == ewFireball)
14211 tempguy.weapon = ewFireball2;
14212 }
14213 }
14214
14215
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.rate),f,keepdata))
14216 {
14217 return qe_invalid;
14218 }
14219
14220
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.step),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230 // HIGHLY UNORTHODOX UPDATING THING, part 2
14231
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 49152 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
50688 if(fixpolsvoice && tempguy.family==eePOLSV)
14232 {
14233 tempguy.step /= 2;
14234 }
14235
14236
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.homing),f,keepdata))
14237 {
14238 return qe_invalid;
14239 }
14240
14241
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14242 {
14243 return qe_invalid;
14244 }
14245
14246
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14247 {
14248 return qe_invalid;
14249 }
14250
14251
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14252 {
14253
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14254 {
14255 return qe_invalid;
14256 }
14257
14258
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14259 {
14260 return qe_invalid;
14261 }
14262
14263
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14264 {
14265 return qe_invalid;
14266 }
14267
14268
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14269 {
14270 return qe_invalid;
14271 }
14272
14273
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14274 {
14275 return qe_invalid;
14276 }
14277
14278
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14279 {
14280 return qe_invalid;
14281 }
14282
14283
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287
14288
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14289 {
14290 return qe_invalid;
14291 }
14292
14293
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14294 {
14295 return qe_invalid;
14296 }
14297
14298
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14299 {
14300 return qe_invalid;
14301 }
14302 50688 }
14303 else
14304 {
14305 int16_t tempMisc;
14306
14307 if(!p_igetw(&tempMisc,f,keepdata))
14308 {
14309 return qe_invalid;
14310 }
14311
14312 tempguy.misc1=tempMisc;
14313
14314 if(!p_igetw(&tempMisc,f,keepdata))
14315 {
14316 return qe_invalid;
14317 }
14318
14319 tempguy.misc2=tempMisc;
14320
14321 if(!p_igetw(&tempMisc,f,keepdata))
14322 {
14323 return qe_invalid;
14324 }
14325
14326 tempguy.misc3=tempMisc;
14327
14328 if(!p_igetw(&tempMisc,f,keepdata))
14329 {
14330 return qe_invalid;
14331 }
14332
14333 tempguy.misc4=tempMisc;
14334
14335 if(!p_igetw(&tempMisc,f,keepdata))
14336 {
14337 return qe_invalid;
14338 }
14339
14340 tempguy.misc5=tempMisc;
14341
14342 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14343 {
14344 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14345 tempguy.misc5 = 74;
14346 }
14347
14348 if(!p_igetw(&tempMisc,f,keepdata))
14349 {
14350 return qe_invalid;
14351 }
14352
14353 tempguy.misc6=tempMisc;
14354
14355 if(!p_igetw(&tempMisc,f,keepdata))
14356 {
14357 return qe_invalid;
14358 }
14359
14360 tempguy.misc7=tempMisc;
14361
14362 if(!p_igetw(&tempMisc,f,keepdata))
14363 {
14364 return qe_invalid;
14365 }
14366
14367 tempguy.misc8=tempMisc;
14368
14369 if(!p_igetw(&tempMisc,f,keepdata))
14370 {
14371 return qe_invalid;
14372 }
14373
14374 tempguy.misc9=tempMisc;
14375
14376 if(!p_igetw(&tempMisc,f,keepdata))
14377 {
14378 return qe_invalid;
14379 }
14380
14381 tempguy.misc10=tempMisc;
14382 }
14383
14384
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14385 {
14386 return qe_invalid;
14387 }
14388
14389
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14390 {
14391 return qe_invalid;
14392 }
14393
14394
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.extend),f,keepdata))
14395 {
14396 return qe_invalid;
14397 }
14398
14399 //! Enemy Defences
14400
14401 //If a 2.50 quest, use only the 2.5 defences.
14402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14403 {
14404
2/2
✓ Branch 0 taken 963072 times.
✓ Branch 1 taken 50688 times.
1013760 for(int32_t j=0; j<edefLAST; j++)
14405 {
14406
1/2
✓ Branch 0 taken 963072 times.
✗ Branch 1 not taken.
963072 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14407 {
14408 return qe_invalid;
14409 }
14410 963072 }
14411 //then copy the generic script defence to all the new script defences
14412
14413 50688 }
14414
14415
14416
14417
14418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(guyversion >= 18)
14419 {
14420
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14421 {
14422 return qe_invalid;
14423 }
14424
14425
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14426 {
14427 return qe_invalid;
14428 }
14429 50688 }
14430
14431
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion >= 22)
14432 {
14433
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14434 {
14435 return qe_invalid;
14436 }
14437
14438
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14439 {
14440 return qe_invalid;
14441 }
14442 50688 }
14443 else if(guyversion >= 19)
14444 {
14445 int16_t tempMisc;
14446
14447 if(!p_igetw(&tempMisc,f,keepdata))
14448 {
14449 return qe_invalid;
14450 }
14451
14452 tempguy.misc11=tempMisc;
14453
14454 if(!p_igetw(&tempMisc,f,keepdata))
14455 {
14456 return qe_invalid;
14457 }
14458
14459 tempguy.misc12=tempMisc;
14460 }
14461
14462 //If a 2.54 or later quest, use all of the defences.
14463
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion > 24) // Add new guyversion conditional statement
14464 {
14465
2/2
✓ Branch 0 taken 259072 times.
✓ Branch 1 taken 11776 times.
270848 for(int32_t j=edefLAST; j<edefLAST255; j++)
14466 {
14467
1/2
✓ Branch 0 taken 259072 times.
✗ Branch 1 not taken.
259072 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14468 {
14469 return qe_invalid;
14470 }
14471 259072 }
14472 11776 }
14473
14474
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14475 {
14476
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14477 {
14478 389120 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14479 389120 }
14480 38912 }
14481
14482 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14483
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion > 25)
14484 {
14485
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14486 {
14487 return qe_invalid;
14488 }
14489
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14490 {
14491 return qe_invalid;
14492 }
14493
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14494 {
14495 return qe_invalid;
14496 }
14497
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14498 {
14499 return qe_invalid;
14500 }
14501
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14502 {
14503 return qe_invalid;
14504 }
14505 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14506
14507 */
14508 11776 }
14509 //More Enemy Editor vars for 2.60
14510
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion > 26)
14511 {
14512
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14513 {
14514 return qe_invalid;
14515 }
14516
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14517 {
14518 return qe_invalid;
14519 }
14520
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14521 {
14522 return qe_invalid;
14523 }
14524
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14525 {
14526 return qe_invalid;
14527 }
14528
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532 11776 }
14533
14534
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14535 {
14536 38912 tempguy.wpnsprite = 0;
14537 38912 }
14538
14539
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion > 27)
14540 {
14541
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14542 {
14543 return qe_invalid;
14544 }
14545 11776 }
14546
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14547 {
14548 38912 tempguy.SIZEflags = 0;
14549 38912 }
14550
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion > 28)
14551 {
14552
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14553 {
14554 return qe_invalid;
14555 }
14556
14557 11776 }
14558
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14559 {
14560 38912 tempguy.frozentile = 0;
14561 38912 tempguy.frozencset = 0;
14562 38912 tempguy.frozenclock = 0;
14563
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14564 38912 }
14565
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion >= 30)
14566 {
14567
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14568 {
14569 return qe_invalid;
14570 }
14571
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14572 {
14573 return qe_invalid;
14574 }
14575
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14576 {
14577 return qe_invalid;
14578 }
14579
2/2
✓ Branch 0 taken 117760 times.
✓ Branch 1 taken 11776 times.
129536 for ( int32_t q = 0; q < 10; q++ ) {
14580
1/2
✓ Branch 0 taken 117760 times.
✗ Branch 1 not taken.
117760 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14581 {
14582 return qe_invalid;
14583 }
14584 117760 }
14585
14586 11776 }
14587
14588
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion >= 34)
14589 {
14590
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14591 {
14592 return qe_invalid;
14593 }
14594
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14595 {
14596 return qe_invalid;
14597 }
14598
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14599 {
14600 return qe_invalid;
14601 }
14602
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14603 {
14604 return qe_invalid;
14605 }
14606
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14607 {
14608 return qe_invalid;
14609 }
14610
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14611 {
14612 return qe_invalid;
14613 }
14614
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14615 {
14616 return qe_invalid;
14617 }
14618
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14619 {
14620 return qe_invalid;
14621 }
14622
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14623 {
14624 return qe_invalid;
14625 }
14626
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14627 {
14628 return qe_invalid;
14629 }
14630
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14631 {
14632 return qe_invalid;
14633 }
14634
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14635 {
14636 return qe_invalid;
14637 }
14638
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14639 {
14640 return qe_invalid;
14641 }
14642
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14643 {
14644 return qe_invalid;
14645 }
14646
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14647 {
14648 return qe_invalid;
14649 }
14650
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14651 {
14652 return qe_invalid;
14653 }
14654
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14655 {
14656 return qe_invalid;
14657 }
14658
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14659 {
14660 return qe_invalid;
14661 }
14662
14663
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 11776 times.
388608 for ( int32_t q = 0; q < 32; q++ ) {
14664
1/2
✓ Branch 0 taken 376832 times.
✗ Branch 1 not taken.
376832 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14665 {
14666 return qe_invalid;
14667 }
14668 376832 }
14669
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 11776 times.
388608 for ( int32_t q = 0; q < 32; q++ ) {
14670
1/2
✓ Branch 0 taken 376832 times.
✗ Branch 1 not taken.
376832 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14671 {
14672 return qe_invalid;
14673 }
14674 376832 }
14675
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.script),f,keepdata))
14676 {
14677 return qe_invalid;
14678 }
14679 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14680
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14681 {
14682
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14683 {
14684 return qe_invalid;
14685 }
14686 94208 }
14687
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 11776 times.
35328 for ( int32_t q = 0; q < 2; q++ )
14688 {
14689
1/2
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
23552 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14690 {
14691 return qe_invalid;
14692 }
14693 23552 }
14694
14695 11776 }
14696
14697
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion >= 37)
14698 {
14699
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14700 {
14701 return qe_invalid;
14702 }
14703 11776 }
14704
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14705
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if(guyversion >= 38)
14706 {
14707
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14708 {
14709 return qe_invalid;
14710 }
14711
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14712 {
14713 return qe_invalid;
14714 }
14715
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14716 {
14717 return qe_invalid;
14718 }
14719
14720 11776 }
14721
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion < 38 )
14722 {
14723 38912 tempguy.misc13 = 0;
14724 38912 tempguy.misc14 = 0;
14725 38912 tempguy.misc15 = 0;
14726 38912 }
14727
14728
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if ( guyversion >= 39 )
14729 {
14730
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14731 {
14732
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
14733 {
14734
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14735 {
14736 return qe_invalid;
14737 }
14738 6123520 }
14739
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
14740 {
14741
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14742 {
14743 return qe_invalid;
14744 }
14745 6123520 }
14746 94208 }
14747
14748
14749 11776 }
14750
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion < 39 ) //apply old InitD strings to both
14751 {
14752
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ )
14753 {
14754 311296 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14755 311296 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14756 311296 }
14757 38912 }
14758
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if ( guyversion >= 40 )
14759 {
14760
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14761 {
14762 return qe_invalid;
14763 }
14764 11776 }
14765
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if ( guyversion < 40 )
14766 {
14767 38912 tempguy.weaponscript = 0;
14768 38912 }
14769 //eweapon script InitD
14770
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
50688 if ( guyversion >= 41 )
14771 {
14772
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14773 {
14774
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14775 {
14776 return qe_invalid;
14777 }
14778 94208 }
14779
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if ( guy_cversion < 4 )
14780 {
14781 if ( tempguy.family == eeKEESE )
14782 {
14783
14784 if ( !tempguy.misc1 )
14785 {
14786 tempguy.misc16 = 120;
14787 tempguy.misc17 = 16;
14788
14789 }
14790 }
14791 if ( tempguy.family == eePEAHAT )
14792 {
14793 tempguy.misc16 = 80;
14794 tempguy.misc17 = 16;
14795 }
14796
14797 if ( tempguy.family == eeGHINI )
14798 {
14799 tempguy.misc16 = 120;
14800 tempguy.misc17 = 10;
14801 }
14802
14803 }
14804 11776 }
14805
14806
14807
14808 //default weapon sprites (quest version < 2.54)
14809 //port over old defaults -Z
14810
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 32)
14811 {
14812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.wpnsprite <= 0 )
14813 {
14814
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14815 {
14816 case wNone:
14817 32390 tempguy.wpnsprite = 0; break;
14818
14819 case wSword:
14820 case wBeam:
14821 case wBrang:
14822 case wBomb:
14823 case wSBomb:
14824 case wLitBomb:
14825 case wLitSBomb:
14826 case wArrow:
14827 case wFire:
14828 case wWhistle:
14829 case wBait:
14830 case wWand:
14831 case wMagic:
14832 case wCatching:
14833 case wWind:
14834 case wRefMagic:
14835 case wRefFireball:
14836 case wRefRock:
14837 case wHammer:
14838 case wHookshot:
14839 case wHSHandle:
14840 case wHSChain:
14841 case wSSparkle:
14842 case wFSparkle:
14843 case wSmack:
14844 case wPhantom:
14845 case wCByrna:
14846 case wRefBeam:
14847 case wStomp:
14848 case lwMax:
14849 case wScript1:
14850 case wScript2:
14851 case wScript3:
14852 case wScript4:
14853 case wScript5:
14854 case wScript6:
14855 case wScript7:
14856 case wScript8:
14857 case wScript9:
14858 case wScript10:
14859 case wIce:
14860 //Cannot use any of these weapons yet.
14861 tempguy.wpnsprite = -1;
14862 break;
14863
14864 case wEnemyWeapons:
14865 1292 case ewFireball: tempguy.wpnsprite = 17; break;
14866
14867 299 case ewArrow: tempguy.wpnsprite = 19; break;
14868 311 case ewBrang: tempguy.wpnsprite = 4; break;
14869 924 case ewSword: tempguy.wpnsprite = 20; break;
14870 488 case ewRock: tempguy.wpnsprite = 18; break;
14871 904 case ewMagic: tempguy.wpnsprite = 21; break;
14872 79 case ewBomb: tempguy.wpnsprite = 78; break;
14873 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14874 135 case ewLitBomb: tempguy.wpnsprite = 76; break;
14875 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14876 359 case ewFireTrail: tempguy.wpnsprite = 80; break;
14877 751 case ewFlame: tempguy.wpnsprite = 35; break;
14878 105 case ewWind: tempguy.wpnsprite = 36; break;
14879 79 case ewFlame2: tempguy.wpnsprite = 81; break;
14880 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14881 case ewIce: tempguy.wpnsprite = 83; break;
14882 759 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14883
14884
14885 default: break; //No assign.
14886 }
14887 38912 }
14888 38912 }
14889
14890 //default weapon fire sound (quest version < 2.54)
14891 //port over old defaults and zero new data. -Z
14892
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 34)
14893 {
14894
2/2
✓ Branch 0 taken 1245184 times.
✓ Branch 1 taken 38912 times.
1284096 for ( int32_t q = 0; q < 32; q++ )
14895 {
14896 1245184 tempguy.movement[q] = 0;
14897 1245184 tempguy.new_weapon[q] = 0;
14898
14899 1245184 }
14900
14901 //NPC Script attributes.
14902 38912 tempguy.script = 0; //No scripted enemies existed. -Z
14903
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14904
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 38912 times.
116736 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14905
14906 38912 tempguy.misc16 = 0;
14907 38912 tempguy.misc17 = 0;
14908 38912 tempguy.misc18 = 0;
14909 38912 tempguy.misc19 = 0;
14910 38912 tempguy.misc20 = 0;
14911 38912 tempguy.misc21 = 0;
14912 38912 tempguy.misc22 = 0;
14913 38912 tempguy.misc23 = 0;
14914 38912 tempguy.misc24 = 0;
14915 38912 tempguy.misc25 = 0;
14916 38912 tempguy.misc26 = 0;
14917 38912 tempguy.misc27 = 0;
14918 38912 tempguy.misc28 = 0;
14919 38912 tempguy.misc29 = 0;
14920 38912 tempguy.misc30 = 0;
14921 38912 tempguy.misc31 = 0;
14922 38912 tempguy.misc32 = 0;
14923
14924 //old default sounds
14925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.firesfx <= 0 )
14926 {
14927
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14928 {
14929 case wNone:
14930 32390 tempguy.firesfx = 0; break;
14931
14932 case wSword:
14933 case wBeam:
14934 case wBrang:
14935 case wBomb:
14936 case wSBomb:
14937 case wLitBomb:
14938 case wLitSBomb:
14939 case wArrow:
14940 case wFire:
14941 case wWhistle:
14942 case wBait:
14943 case wWand:
14944 case wMagic:
14945 case wCatching:
14946 case wWind:
14947 case wRefMagic:
14948 case wRefFireball:
14949 case wRefRock:
14950 case wHammer:
14951 case wHookshot:
14952 case wHSHandle:
14953 case wHSChain:
14954 case wSSparkle:
14955 case wFSparkle:
14956 case wSmack:
14957 case wPhantom:
14958 case wCByrna:
14959 case wRefBeam:
14960 case wStomp:
14961 case lwMax:
14962 case wScript1:
14963 case wScript2:
14964 case wScript3:
14965 case wScript4:
14966 case wScript5:
14967 case wScript6:
14968 case wScript7:
14969 case wScript8:
14970 case wScript9:
14971 case wScript10:
14972 case wIce:
14973 //Cannot use any of these weapons yet.
14974 tempguy.firesfx = -1;
14975 break;
14976
14977 case wEnemyWeapons:
14978 1292 case ewFireball: tempguy.firesfx = 40; break;
14979
14980 299 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14981 311 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14982 924 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14983 488 case ewRock: tempguy.firesfx = 51; break;
14984 904 case ewMagic: tempguy.firesfx = 32; break;
14985 79 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14986 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14987 135 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14988 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14989 359 case ewFireTrail: tempguy.firesfx = 13; break;
14990 751 case ewFlame: tempguy.firesfx = 13; break;
14991 105 case ewWind: tempguy.firesfx = 32; break;
14992 79 case ewFlame2: tempguy.firesfx = 13; break;
14993 case ewFlame2Trail: tempguy.firesfx = 13; break;
14994 case ewIce: tempguy.firesfx = 44; break;
14995 759 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14996
14997 //what about special attacks (e.g. summoning == 56)
14998 default: break; //No assign.
14999 }
15000 38912 }
15001 38912 }
15002
15003 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
15004
4/6
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 11776 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11776 times.
50688 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
15005 {
15006
2/2
✓ Branch 0 taken 3527 times.
✓ Branch 1 taken 35385 times.
38912 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
15007 38912 }
15008 //Keese and bat halt rates.
15009
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 11776 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
50688 if ( guyversion < 42 && guy_cversion < 4 )
15010 {
15011
15012
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 524 times.
38912 if ( tempguy.family == eeKEESE )
15013 {
15014
15015
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 322 times.
524 if ( !tempguy.misc1 )
15016 {
15017 322 tempguy.misc16 = 120;
15018 322 tempguy.misc17 = 16;
15019
15020 322 }
15021 524 }
15022
2/2
✓ Branch 0 taken 38747 times.
✓ Branch 1 taken 165 times.
38912 if ( tempguy.family == eePEAHAT )
15023 {
15024 165 tempguy.misc16 = 80;
15025 165 tempguy.misc17 = 16;
15026 165 }
15027
2/2
✓ Branch 0 taken 38836 times.
✓ Branch 1 taken 76 times.
38912 if ( tempguy.family == eeGHINI )
15028 {
15029 76 tempguy.misc16 = 120;
15030 76 tempguy.misc17 = 10;
15031 76 }
15032
15033
15034 38912 }
15035
15036
15037 //miscellaneous other corrections
15038 //fix the mirror wizzrobe -DD
15039
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 7)
15040 {
15041 if(i == eMWIZ)
15042 {
15043 tempguy.misc2 = 0;
15044 tempguy.misc4 = 1;
15045 }
15046 }
15047
15048
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 8)
15049 {
15050 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15051 {
15052 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15053 tempguy.misc5 = 4; //neck length in segments
15054 tempguy.misc6 = 8; //neck offset from first body tile
15055 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15056 tempguy.misc8 = 168; //head offset from first body tile
15057 tempguy.misc9 = 228; //flying head offset from first body tile
15058
15059 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15060 {
15061 tempguy.misc6 += 10; //neck offset from first body tile
15062 tempguy.misc8 -= 12; //head offset from first body tile
15063 }
15064 }
15065 }
15066
15067
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15068 {
15069 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15070 tempguy.bosspal = spDIG;
15071 }
15072
15073
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 11) // December 2007 - Spinning Tile fix
15074 {
15075 if(tempguy.family==eeSPINTILE)
15076 {
15077 tempguy.flags |= guy_superman;
15078 tempguy.item_set = 0; // Don't drop items
15079 tempguy.step = 300;
15080 }
15081 }
15082
15083
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15084 {
15085 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15086 {
15087 if(tempguy.family==eeROPE)
15088 {
15089 tempguy.flags2 &= ~guy_flashing;
15090 }
15091 }
15092
15093 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15094 {
15095 if(tempguy.family==eeBUBBLE)
15096 {
15097 tempguy.flags2 &= ~guy_flashing;
15098 }
15099 }
15100
15101 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15102 {
15103 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15104 {
15105 tempguy.flags2 |= guy_blinking;
15106 }
15107
15108 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15109 {
15110 tempguy.flags2 |= guy_transparent;
15111 }
15112 }
15113 }
15114
15115
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15116 {
15117 if(i==gFIRE)
15118 {
15119 tempguy.e_anim = aFLIP;
15120 tempguy.e_frate = 24;
15121 }
15122
15123 if(i==gFAIRY)
15124 {
15125 tempguy.e_anim = a2FRM;
15126 tempguy.e_frate = 16;
15127 }
15128 }
15129
15130
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15131 {
15132 if(i==0) Z_message("Updating guys to version 16...\n");
15133
15134 update_guy_1(&tempguy);
15135
15136 if(i==eMPOLSV)
15137 {
15138 tempguy.defense[edefARROW] = edCHINK;
15139 tempguy.defense[edefMAGIC] = ed1HKO;
15140 tempguy.defense[edefREFMAGIC] = ed1HKO;
15141 }
15142 }
15143
15144
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 17) // December 2009
15145 {
15146 if(tempguy.family==eePROJECTILE)
15147 {
15148 tempguy.misc1 = 0;
15149 }
15150 }
15151
15152
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 18) // January 2010
15153 {
15154 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15155 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15156
15157 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15158 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15159
15160 if(tempguy.family == eeAQUA)
15161 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15162 else if(tempguy.family == eeMANHAN)
15163 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15164 else if(tempguy.family==eePATRA)
15165 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15166 else if(tempguy.family==eeGHOMA)
15167 {
15168 for(int32_t j=0; j<edefLAST; j++)
15169 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15170
15171 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15172
15173 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15174
15175 tempguy.misc1--;
15176 }
15177 else if(tempguy.family == eeGLEEOK)
15178 {
15179 for(int32_t j=0; j<edefLAST; j++)
15180 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15181
15182 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15183 }
15184 else if(tempguy.family == eeARMOS)
15185 {
15186 tempguy.family=eeWALK;
15187 tempguy.hrate = 0;
15188 tempguy.misc10 = tempguy.misc1;
15189 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15190 tempguy.misc9 = e9tARMOS;
15191 }
15192 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15193 {
15194 tempguy.family=eeWALK;
15195 tempguy.hrate = 0;
15196 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15197 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15198 }
15199
15200 // Spawn animation flags
15201 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15202 tempguy.flags |= guy_fadeflicker;
15203 else
15204 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15205 }
15206
15207
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 20) // April 2010
15208 {
15209 if(tempguy.family == eeTRAP)
15210 {
15211 tempguy.misc2 = tempguy.misc10;
15212
15213 if(tempguy.misc10>=1)
15214 {
15215 tempguy.misc1++;
15216 }
15217
15218 tempguy.misc10 = 0;
15219 }
15220
15221 // Bomb Blast fix
15222 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15223 tempguy.weapon = ewLitBomb;
15224 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15225 tempguy.weapon = ewLitSBomb;
15226 }
15227
15228
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 21) // September 2011
15229 {
15230 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15231 {
15232 if(tempguy.family == eeKEESETRIB)
15233 {
15234 tempguy.family = eeKEESE;
15235 tempguy.misc2 = e2tKEESETRIB;
15236 tempguy.misc1 = 0;
15237 }
15238
15239 tempguy.rate = 2;
15240 tempguy.hrate = 8;
15241 tempguy.homing = 0;
15242 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15243 }
15244 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15245 {
15246 if(tempguy.family == eePEAHAT)
15247 {
15248 tempguy.rate = 4;
15249 tempguy.step = 62;
15250 }
15251 else
15252 tempguy.step = 25;
15253
15254 tempguy.hrate = 8;
15255 tempguy.homing = 0;
15256 }
15257 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15258 {
15259 if(tempguy.family == eeMANHAN)
15260 tempguy.step=50;
15261
15262 tempguy.hrate = 16;
15263 tempguy.homing = 0;
15264 }
15265 else if(tempguy.family == eeGLEEOK)
15266 {
15267 tempguy.rate = 2;
15268 tempguy.homing = 0;
15269 tempguy.hrate = 9;
15270 tempguy.step=89;
15271 }
15272 else if(tempguy.family == eeGHINI)
15273 {
15274 tempguy.rate = 4;
15275 tempguy.hrate = 12;
15276 tempguy.step=62;
15277 tempguy.homing = 0;
15278 }
15279
15280 // Bigdig random rate fix
15281 if(tempguy.family==eeDIG && tempguy.misc10==1)
15282 {
15283 tempguy.rate = 2;
15284 }
15285 }
15286
15287
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 24) // November 2012
15288 {
15289 if(tempguy.family==eeLANM)
15290 tempguy.misc3 = 1;
15291 else if(tempguy.family==eeMOLD)
15292 tempguy.misc2 = 0;
15293 }
15294
15295
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15296 {
15297
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 38258 times.
38912 if(tempguy.family!=eeDIG)
15298 {
15299 38258 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15300 38258 }
15301
15302 38912 }
15303 // does not seem to solve the issue!
15304
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if ( Header->zelda_version <= 0x210 )
15305 {
15306 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15307 if ( tempguy.family == eeDONGO )
15308 {
15309 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15310 }
15311 }
15312
15313
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion >= 42)
15314 {
15315
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 1024 times.
11776 if(guyversion >= 47)
15316 {
15317
1/2
✓ Branch 0 taken 10752 times.
✗ Branch 1 not taken.
10752 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15318 {
15319 return qe_invalid;
15320 }
15321 10752 }
15322 else
15323 {
15324 byte fl;
15325
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15326 {
15327 return qe_invalid;
15328 }
15329 1024 tempguy.moveflags = fl;
15330 }
15331 11776 }
15332 else
15333 {
15334
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30458 times.
✓ Branch 2 taken 1192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 275 times.
✓ Branch 6 taken 239 times.
✓ Branch 7 taken 5787 times.
38912 switch(tempguy.family)
15335 {
15336 //No gravity; floats over pits
15337 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15338 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15339 //Special (bosses, etc)
15340 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15341 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15342 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15343 30458 tempguy.moveflags = FLAG_CAN_PITWALK;
15344 30458 break;
15345 //No gravity, but falls in pits
15346 case eeLEV:
15347 515 tempguy.moveflags = FLAG_CAN_PITFALL;
15348 515 break;
15349 //Bosses that respect pits
15350 case eeDONGO:
15351 275 tempguy.moveflags = FLAG_OBEYS_GRAV;
15352 275 break;
15353 case eeLANM:
15354 239 tempguy.moveflags = 0;
15355 239 break;
15356 //Gravity, floats over pits
15357 case eeWIZZ: case eeWALLM: case eeGHINI:
15358 1192 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15359 1192 break;
15360 //Gravity and falls in pits
15361 case eeWALK:
15362
4/4
✓ Branch 0 taken 5469 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 5191 times.
5787 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15363 596 break;
15364 [[fallthrough]];
15365 case eeOTHER:
15366 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15367 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15368 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15369 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15370 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15371 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15372 5637 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15373 5637 }
15374 }
15375
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 43)
15376 {
15377
2/2
✓ Branch 0 taken 31650 times.
✓ Branch 1 taken 7262 times.
38912 switch(tempguy.family)
15378 {
15379 //No gravity; floats over pits
15380 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15381 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15382 //Special (bosses, etc)
15383 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15384 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15385 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15386 case eeWIZZ: case eeWALLM: case eeGHINI:
15387 //Gravity, floats over pits
15388 31650 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15389 31650 break;
15390 }
15391 38912 }
15392
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if (guyversion < 44)
15393 {
15394
2/2
✓ Branch 0 taken 38546 times.
✓ Branch 1 taken 366 times.
38912 if ( tempguy.family == eeGHOMA )
15395 {
15396 366 tempguy.flags |= guy_fadeinstant;
15397 366 }
15398 38912 }
15399
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if (guyversion > 44)
15400 {
15401
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15402 {
15403 return qe_invalid;
15404 }
15405
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15406 {
15407 return qe_invalid;
15408 }
15409
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15410 {
15411 return qe_invalid;
15412 }
15413 11776 }
15414 else
15415 {
15416
2/2
✓ Branch 0 taken 38761 times.
✓ Branch 1 taken 151 times.
38912 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15417 38912 tempguy.spr_death = iwDeath;
15418 38912 tempguy.spr_spawn = iwSpawn;
15419 }
15420
15421
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 38912 times.
50688 if(guyversion < 46)
15422 {
15423
4/4
✓ Branch 0 taken 5787 times.
✓ Branch 1 taken 33125 times.
✓ Branch 2 taken 5469 times.
✓ Branch 3 taken 318 times.
38912 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15424 {
15425 318 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15426 318 }
15427 38912 }
15428
15429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(keepdata)
15430 {
15431 50688 guysbuf[i] = tempguy;
15432 50688 }
15433 50688 }
15434 99 }
15435
15436 99 return 0;
15437 108 }
15438
15439 void update_guy_1(guydata *tempguy) // November 2009
15440 {
15441 bool doesntcount = false;
15442 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15443
15444 switch(tempguy->family)
15445 {
15446 case 1: //eeWALK
15447 switch(tempguy->misc10)
15448 {
15449 case 0: //Stalfos
15450 if(tempguy->misc1==1) // Fires four projectiles at once
15451 tempguy->misc1=4;
15452
15453 break;
15454
15455 case 1: //Darknut
15456 goto darknuts;
15457 break;
15458 }
15459
15460 tempguy->misc10 = 0;
15461 break;
15462
15463 case 2: //eeSHOOT
15464 tempguy->family = eeWALK;
15465
15466 switch(tempguy->misc10)
15467 {
15468 case 0: //Octorok
15469 if(tempguy->misc1==1||tempguy->misc1==2)
15470 {
15471 tempguy->misc1=e1tFIREOCTO;
15472 tempguy->misc2=e2tFIREOCTO;
15473 }
15474 else tempguy->misc1 = 0;
15475
15476 tempguy->misc6=tempguy->misc4;
15477 tempguy->misc4=tempguy->misc3;
15478 tempguy->misc3=0;
15479 break;
15480
15481 case 1: // Moblin
15482 tempguy->misc1 = 0;
15483 break;
15484
15485 case 2: //Lynel
15486 tempguy->misc6=tempguy->misc1+1;
15487 tempguy->misc1=0;
15488 break;
15489
15490 case 3: //Stalfos 2
15491 if(tempguy->misc1==1) // Fires four projectiles at once
15492 tempguy->misc1=e1t4SHOTS;
15493 else tempguy->misc1 = 0;
15494
15495 break;
15496
15497 case 4: //Darknut 5
15498 darknuts:
15499 tempguy->defense[edefFIRE] = edIGNORE;
15500 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15501 tempguy->defense[edefHOOKSHOT] = 0;
15502 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15503 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15504
15505 if(tempguy->misc1==1)
15506 tempguy->misc1=2;
15507 else if(tempguy->misc1==2)
15508 {
15509 tempguy->misc4=tempguy->misc3;
15510 tempguy->misc3=tempguy->misc2;
15511 tempguy->misc2=e2tSPLIT;
15512 tempguy->misc1 = 0;
15513 }
15514 else tempguy->misc1 = 0;
15515
15516 tempguy->flags |= inv_front;
15517
15518 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15519 tempguy->flags |= guy_bkshield;
15520
15521 break;
15522 }
15523
15524 tempguy->misc10 = 0;
15525 break;
15526
15527 /*
15528 case 9: //eeARMOS
15529 tempguy->family = eeWALK;
15530 break;
15531 */
15532 case 11: //eeGEL
15533 case 33: //eeGELTRIB
15534 if(tempguy->family==33)
15535 {
15536 tempguy->misc4 = 1;
15537
15538 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15539 tempguy->misc3 = tempguy->misc2;
15540
15541 tempguy->misc2 = e2tTRIBBLE;
15542 }
15543 else
15544 {
15545 tempguy->misc4 = 0;
15546 tempguy->misc3 = 0;
15547 tempguy->misc2 = 0;
15548 }
15549
15550 tempguy->family = eeWALK;
15551
15552 if(tempguy->misc1)
15553 {
15554 tempguy->misc1=1;
15555 tempguy->weapon = ewFireTrail;
15556 }
15557
15558 break;
15559
15560 case 34: //eeZOLTRIB
15561 case 12: //eeZOL
15562 tempguy->misc4=tempguy->misc3;
15563 tempguy->misc3=tempguy->misc2;
15564 tempguy->family = eeWALK;
15565 tempguy->misc2=e2tSPLITHIT;
15566
15567 if(tempguy->misc1)
15568 {
15569 tempguy->misc1=1;
15570 tempguy->weapon = ewFireTrail;
15571 }
15572
15573 break;
15574
15575 case 13: //eeROPE
15576 tempguy->family = eeWALK;
15577 tempguy->misc9 = e9tROPE;
15578
15579 if(tempguy->misc1)
15580 {
15581 tempguy->misc4 = tempguy->misc3;
15582 tempguy->misc3 = tempguy->misc2;
15583 tempguy->misc2 = e2tBOMBCHU;
15584 }
15585
15586 tempguy->misc1 = 0;
15587 break;
15588
15589 case 14: //eeGORIYA
15590 tempguy->family = eeWALK;
15591
15592 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15593
15594 break;
15595
15596 case 17: //eeBUBBLE
15597 tempguy->family = eeWALK;
15598 tempguy->misc8 = tempguy->misc2;
15599 tempguy->misc7 = tempguy->misc1 + 1;
15600 tempguy->misc1 = tempguy->misc2 = 0;
15601
15602 //fallthrogh
15603 case eeTRAP:
15604 case eeROCK:
15605 doesntcount = true;
15606 break;
15607
15608 case 35: //eeVIRETRIB
15609 case 18: //eeVIRE
15610 tempguy->family = eeWALK;
15611 tempguy->misc4=tempguy->misc3;
15612 tempguy->misc3=tempguy->misc2;
15613 tempguy->misc2=e2tSPLITHIT;
15614 tempguy->misc9=e9tVIRE;
15615 break;
15616
15617 case 19: //eeLIKE
15618 tempguy->family = eeWALK;
15619 tempguy->misc7 = e7tEATITEMS;
15620 tempguy->misc8=95;
15621 break;
15622
15623 case 20: //eePOLSV
15624 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15625 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15626 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15627 tempguy->defense[edefARROW] = ed1HKO;
15628 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15629 tempguy->family = eeWALK;
15630 tempguy->misc9 = e9tPOLSVOICE;
15631 tempguy->rate = 4;
15632 tempguy->homing = 32;
15633 tempguy->hrate = 10;
15634 tempguy->grumble = 0;
15635 break;
15636
15637 case eeWIZZ:
15638 if(tempguy->misc4)
15639 {
15640 for(int32_t i=0; i < edefLAST; i++)
15641 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15642 }
15643 else
15644 {
15645 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15646 tempguy->defense[edefMAGIC] = edCHINK;
15647 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15648 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15649 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15650 }
15651
15652 break;
15653
15654 case eePEAHAT:
15655 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15656
15657 if(!(tempguy->flags & guy_bhit))
15658 tempguy->defense[edefBRANG] = edSTUNONLY;
15659
15660 break;
15661
15662 case eeLEV:
15663 tempguy->defense[edefSTOMP] = edCHINK;
15664 break;
15665 }
15666
15667 // Old flags
15668 if(tempguy->flags & guy_superman)
15669 {
15670 for(int32_t i = 0; i < edefLAST; i++)
15671 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15672 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15673 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15674 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15675 }
15676
15677 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15678
15679 if(doesntcount)
15680 tempguy->flags |= (guy_doesntcount);
15681 }
15682
15683
15684 187744 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15685 {
15686 byte tempbyte, padding;
15687 int32_t extras, secretcombos;
15688 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->valid),f,true))
15690 {
15691 return qe_invalid;
15692 }
15693
15694
15695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->guy),f,true))
15696 {
15697 return qe_invalid;
15698 }
15699
15700
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15701 {
15702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15703 {
15704 return qe_invalid;
15705 }
15706
15707 6864 temp_mapscr->str=tempbyte;
15708 6864 }
15709 else
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->str),f,true))
15712 {
15713 return qe_invalid;
15714 }
15715 }
15716
15717
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->room),f,true))
15718 {
15719 return qe_invalid;
15720 }
15721
15722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->item),f,true))
15723 {
15724 return qe_invalid;
15725 }
15726
15727
3/6
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153000 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15728 {
15729 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15730 34744 }
15731 else
15732 {
15733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15734 return qe_invalid;
15735 }
15736
15737
2/4
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version < 0x192)||
15738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15739 {
15740
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15741 {
15742 return qe_invalid;
15743 }
15744 6864 }
15745
15746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15747 {
15748 return qe_invalid;
15749 }
15750
15751
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15752 {
15753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15754 {
15755 return qe_invalid;
15756 }
15757 6864 }
15758
15759
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15760 {
15761
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15762 {
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15764 {
15765 return qe_invalid;
15766 }
15767 459000 }
15768 153000 }
15769 else
15770 {
15771 34744 temp_mapscr->tilewarptype[1]=0;
15772 34744 temp_mapscr->tilewarptype[2]=0;
15773 34744 temp_mapscr->tilewarptype[3]=0;
15774 }
15775
15776
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15777 {
15778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15779 {
15780 return qe_invalid;
15781 }
15782 180880 }
15783
15784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15785 {
15786 return qe_invalid;
15787 }
15788
15789 187744 temp_mapscr->warpreturnx[1]=0;
15790 187744 temp_mapscr->warpreturnx[2]=0;
15791 187744 temp_mapscr->warpreturnx[3]=0;
15792
15793
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15794 {
15795
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15796 {
15797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15798 {
15799 return qe_invalid;
15800 }
15801 459000 }
15802 153000 }
15803
15804
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15805 {
15806 return qe_invalid;
15807 }
15808
15809 187744 temp_mapscr->warpreturny[1]=0;
15810 187744 temp_mapscr->warpreturny[2]=0;
15811 187744 temp_mapscr->warpreturny[3]=0;
15812
15813
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15814 {
15815
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15816 {
15817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15818 {
15819 return qe_invalid;
15820 }
15821 459000 }
15822
15823
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(version>=18)
15824 {
15825
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15826 {
15827 return qe_invalid;
15828 }
15829 153000 }
15830 else
15831 {
15832 byte temp;
15833
15834 if(!p_getc(&temp,f,true))
15835 {
15836 return qe_invalid;
15837 }
15838
15839 temp_mapscr->warpreturnc=temp<<8|temp;
15840 }
15841 153000 }
15842
15843
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->stairx),f,true))
15844
15845 {
15846 return qe_invalid;
15847 }
15848
15849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->stairy),f,true))
15850 {
15851 return qe_invalid;
15852 }
15853
15854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemx),f,true))
15855 {
15856 return qe_invalid;
15857 }
15858
15859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemy),f,true))
15860 {
15861 return qe_invalid;
15862 }
15863
15864
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version > 15) // February 2009
15865 {
15866
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->color),f,true))
15867 {
15868 return qe_invalid;
15869 }
15870 153000 }
15871 else
15872 {
15873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15874 {
15875 return qe_invalid;
15876 }
15877
15878 34744 temp_mapscr->color = (word) tempbyte;
15879 }
15880
15881
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15882 {
15883 return qe_invalid;
15884 }
15885
15886
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
15887 {
15888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15889 {
15890 return qe_invalid;
15891
15892 }
15893 750976 }
15894
15895
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
15896 {
15897
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
15898 {
15899 return qe_invalid;
15900 }
15901
15902 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15903
15904
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15905 {
15906 for(int32_t i=1; i<4; i++)
15907 {
15908 if(!p_getc(&(tempbyte),f,true))
15909 {
15910 return qe_invalid;
15911 }
15912
15913 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15914 }
15915 }
15916 else
15917 {
15918 34744 temp_mapscr->tilewarpdmap[1]=0;
15919 34744 temp_mapscr->tilewarpdmap[2]=0;
15920 34744 temp_mapscr->tilewarpdmap[3]=0;
15921 }
15922 34744 }
15923 else
15924 {
15925
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
15926 {
15927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15928 {
15929 return qe_invalid;
15930 }
15931 612000 }
15932 }
15933
15934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15935 {
15936 return qe_invalid;
15937 }
15938
15939
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15940 {
15941
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15942 {
15943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15944 {
15945 return qe_invalid;
15946 }
15947 459000 }
15948 153000 }
15949 else
15950 {
15951 34744 temp_mapscr->tilewarpscr[1]=0;
15952 34744 temp_mapscr->tilewarpscr[2]=0;
15953 34744 temp_mapscr->tilewarpscr[3]=0;
15954 }
15955
15956
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
15957 {
15958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15959 {
15960 return qe_invalid;
15961 }
15962 153000 }
15963 else
15964 {
15965 34744 temp_mapscr->tilewarpoverlayflags=0;
15966 }
15967
15968
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15969 {
15970 return qe_invalid;
15971 }
15972
15973
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15974 {
15975
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15976 {
15977 return qe_invalid;
15978 }
15979
15980 6864 }
15981
15982
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15983 {
15984 if(!p_getc(&padding,f,true))
15985 {
15986 return qe_invalid;
15987 }
15988 }
15989
15990
2/2
✓ Branch 0 taken 1877440 times.
✓ Branch 1 taken 187744 times.
2065184 for(int32_t k=0; k<10; k++)
15991 {
15992 /*
15993 if (!temp_mapscr->enemy[k])
15994 {
15995 continue;
15996 }
15997 */
15998
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15999 {
16000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16001 {
16002 return qe_invalid;
16003 }
16004
16005 68640 temp_mapscr->enemy[k]=tempbyte;
16006 68640 }
16007 else
16008 {
16009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1808800 times.
1808800 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
16010 {
16011 return qe_invalid;
16012 }
16013 }
16014
16015
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16016 {
16017 //using enumerations here is dangerous
16018 //very easy to break old quests -DD
16019
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16020 {
16021 788 temp_mapscr->enemy[k]+=5;
16022 788 }
16023
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16024 {
16025 40 temp_mapscr->enemy[k]+=1;
16026 40 }
16027 68640 }
16028
16029
2/2
✓ Branch 0 taken 1530000 times.
✓ Branch 1 taken 347440 times.
1877440 if(version < 9)
16030 {
16031
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
16032 {
16033 29025 temp_mapscr->enemy[k]+=10;
16034 29025 }
16035 347440 }
16036 //don't read in any invalid data
16037
2/2
✓ Branch 0 taken 1877420 times.
✓ Branch 1 taken 20 times.
1877440 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16038 {
16039 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16040 20 temp_mapscr->enemy[k] = 0;
16041 20 }
16042 1877440 }
16043
16044
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->pattern),f,true))
16045 {
16046 return qe_invalid;
16047 }
16048
16049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16050 {
16051 return qe_invalid;
16052 }
16053
16054
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16055 {
16056
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
16057 {
16058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16059 {
16060 return qe_invalid;
16061 }
16062 459000 }
16063 153000 }
16064 else
16065 {
16066 34744 temp_mapscr->sidewarptype[1]=0;
16067 34744 temp_mapscr->sidewarptype[2]=0;
16068 34744 temp_mapscr->sidewarptype[3]=0;
16069 }
16070
16071
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
16072 {
16073
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16074 {
16075 return qe_invalid;
16076 }
16077 153000 }
16078 else
16079 {
16080 34744 temp_mapscr->sidewarpoverlayflags=0;
16081 }
16082
16083
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16084 {
16085 return qe_invalid;
16086 }
16087
16088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16089 {
16090 return qe_invalid;
16091 }
16092
16093
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
16094 {
16095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16096 {
16097 return qe_invalid;
16098 }
16099 750976 }
16100
16101
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16102 {
16103 return qe_invalid;
16104 }
16105
16106
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16107 {
16108
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 459000 times.
612000 for(int32_t i=1; i<4; i++)
16109 {
16110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16111 {
16112 return qe_invalid;
16113 }
16114 459000 }
16115 153000 }
16116 else
16117 {
16118 34744 temp_mapscr->sidewarpscr[1]=0;
16119 34744 temp_mapscr->sidewarpscr[2]=0;
16120 34744 temp_mapscr->sidewarpscr[3]=0;
16121 }
16122
16123
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
16124 {
16125
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16126 {
16127 return qe_invalid;
16128 }
16129
16130 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16131
16132
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16133 {
16134 for(int32_t i=1; i<4; i++)
16135 {
16136 if(!p_getc(&(tempbyte),f,true))
16137 {
16138 return qe_invalid;
16139 }
16140
16141 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16142 }
16143 }
16144 else
16145 {
16146 34744 temp_mapscr->sidewarpdmap[1]=0;
16147 34744 temp_mapscr->sidewarpdmap[2]=0;
16148 34744 temp_mapscr->sidewarpdmap[3]=0;
16149 }
16150 34744 }
16151 else
16152 {
16153
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
16154 {
16155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16156 {
16157 return qe_invalid;
16158 }
16159 612000 }
16160 }
16161
16162
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16163 {
16164
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16165 {
16166 return qe_invalid;
16167 }
16168 153000 }
16169 34744 else temp_mapscr->sidewarpindex = 0;
16170
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16172 {
16173 return qe_invalid;
16174 }
16175
16176
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
16177 {
16178
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16179 {
16180 return qe_invalid;
16181 }
16182 6864 }
16183
16184
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16185 {
16186 return qe_invalid;
16187 }
16188
16189
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16190 {
16191 return qe_invalid;
16192 }
16193
16194
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->flags),f,true))
16195 {
16196 return qe_invalid;
16197 }
16198
16199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags2),f,true))
16200 {
16201 return qe_invalid;
16202 }
16203
16204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags3),f,true))
16205 {
16206 return qe_invalid;
16207 }
16208
16209
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16210 //if (version>2)
16211 {
16212
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags4),f,true))
16213 {
16214 return qe_invalid;
16215 }
16216 153000 }
16217
16218
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16219 {
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags5),f,true))
16221 {
16222 return qe_invalid;
16223 }
16224
16225
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16226 {
16227 return qe_invalid;
16228 }
16229
16230
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16231 {
16232 return qe_invalid;
16233 }
16234
16235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(temp_mapscr->flags5&32)
16236 {
16237 temp_mapscr->flags5 &= ~32;
16238 temp_mapscr->noreset |= 48;
16239 }
16240
16241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(version<8)
16242 {
16243 if(temp_mapscr->noreset&1)
16244 {
16245 temp_mapscr->noreset|=8192;
16246 }
16247
16248 if(temp_mapscr->nocarry&1)
16249 {
16250 temp_mapscr->nocarry|=8192;
16251 temp_mapscr->nocarry&=~1;
16252 }
16253 }
16254 153000 }
16255 else
16256 {
16257 34744 temp_mapscr->flags5 = 0;
16258 34744 temp_mapscr->noreset = 0;
16259 34744 temp_mapscr->nocarry = 0;
16260 }
16261
16262
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16263 {
16264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags6),f,true))
16265 {
16266 return qe_invalid;
16267 }
16268 153000 }
16269
16270
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>5)
16271 {
16272
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags7),f,true))
16273 {
16274 return qe_invalid;
16275 }
16276
16277
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags8),f,true))
16278 {
16279 return qe_invalid;
16280 }
16281
16282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags9),f,true))
16283 {
16284 return qe_invalid;
16285 }
16286
16287
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags10),f,true))
16288 {
16289 return qe_invalid;
16290 }
16291
16292
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16293 {
16294 return qe_invalid;
16295 }
16296 153000 }
16297 else
16298 {
16299 34744 temp_mapscr->csensitive=1;
16300 }
16301
16302
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<14) // August 2007: screen SFX added
16303 {
16304
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16305 {
16306 100 temp_mapscr->bosssfx=
16307
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16308 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16309 WAV_ROAR;
16310 100 }
16311
16312
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16313 {
16314 91 temp_mapscr->oceansfx=WAV_SEA;
16315 91 }
16316
16317 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16318 ? 0 : WAV_SECRET;
16319
16320 34744 temp_mapscr->flags3 &= ~66; //64|2
16321 34744 temp_mapscr->flags2 &= ~32;
16322 34744 temp_mapscr->flags &= ~136; // 128|8
16323 34744 }
16324 else
16325 {
16326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16327 {
16328 return qe_invalid;
16329 }
16330
16331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16332 {
16333 return qe_invalid;
16334 }
16335
16336
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16337 {
16338 return qe_invalid;
16339 }
16340 }
16341
16342
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<15) // October 2007: another SFX
16343 {
16344 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16345 34744 }
16346 else
16347 {
16348
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16349 {
16350 return qe_invalid;
16351 }
16352 }
16353
16354
16355
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16356 {
16357
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16358 {
16359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16360 {
16361 return qe_invalid;
16362 }
16363 1085280 }
16364
16365
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 1085280 times.
1266160 for(int32_t k=0; k<6; k++)
16366 {
16367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16368 {
16369 return qe_invalid;
16370 }
16371 1085280 }
16372 180880 }
16373
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16374 {
16375 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16376 {
16377 return qe_invalid;
16378 }
16379
16380 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16381 {
16382 return qe_invalid;
16383 }
16384
16385 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16386 {
16387 return qe_invalid;
16388 }
16389
16390 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16391
16392 {
16393 return qe_invalid;
16394 }
16395 }
16396
16397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>149))
16398 {
16399 for(int32_t k=0; k<6; k++)
16400 {
16401 if(!p_getc(&tempbyte,f,true)) //layerxsize
16402 {
16403 return qe_invalid;
16404 }
16405 }
16406
16407 for(int32_t k=0; k<6; k++)
16408 {
16409 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16410 {
16411 return qe_invalid;
16412 }
16413 }
16414
16415 for(int32_t k=0; k<6; k++)
16416 {
16417 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16418 {
16419 return qe_invalid;
16420 }
16421 }
16422
16423 for(int32_t k=0; k<6; k++)
16424 {
16425 if(!p_getc(&tempbyte,f,true)) //layerysize
16426 {
16427 return qe_invalid;
16428 }
16429 }
16430
16431 for(int32_t k=0; k<6; k++)
16432 {
16433 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16434 {
16435 return qe_invalid;
16436 }
16437 }
16438
16439 for(int32_t k=0; k<6; k++)
16440 {
16441 if(!p_getc(&tempbyte,f,true)) //layerydelay
16442 {
16443 return qe_invalid;
16444 }
16445 }
16446 }
16447
16448
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16449 {
16450
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16451 {
16452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16453 {
16454 return qe_invalid;
16455 }
16456 1085280 }
16457 180880 }
16458
16459
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16460 {
16461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 if((Header->zelda_version == 0x192)&&(Header->build>153))
16462 {
16463 if(!p_getc(&padding,f,true))
16464 {
16465 return qe_invalid;
16466 }
16467 }
16468
16469
1/2
✓ Branch 0 taken 180880 times.
✗ Branch 1 not taken.
180880 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16470 {
16471 return qe_invalid;
16472 }
16473 180880 }
16474
16475
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16476 {
16477 6864 extras=15;
16478 6864 }
16479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16480 {
16481 extras=11;
16482 }
16483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16484 {
16485 extras=32;
16486 }
16487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16488 {
16489 extras=64;
16490 }
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 else if(Header->zelda_version < 0x193)
16492 {
16493 extras=62;
16494 }
16495 else
16496
16497 {
16498 180880 extras=0;
16499 }
16500
16501
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 187744 times.
290704 for(int32_t k=0; k<extras; k++)
16502 {
16503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16504 {
16505 return qe_invalid;
16506 }
16507 102960 }
16508
16509
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16510 //if (version>3)
16511 {
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16513 {
16514 return qe_invalid;
16515 }
16516
16517
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16518 {
16519 return qe_invalid;
16520 }
16521 153000 }
16522 else
16523 {
16524 34744 temp_mapscr->nextmap=0;
16525 34744 temp_mapscr->nextscr=0;
16526 }
16527
16528
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16529 {
16530 6864 secretcombos=20;
16531 6864 }
16532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16533 {
16534 secretcombos=256;
16535 }
16536 else
16537 {
16538 180880 secretcombos=128;
16539 }
16540
16541
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16542 {
16543
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16544 {
16545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16546 {
16547 return qe_invalid;
16548 }
16549
16550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16551 {
16552 137280 temp_mapscr->secretcombo[k]=tempbyte;
16553 137280 }
16554 137280 }
16555 6864 }
16556 else
16557 {
16558
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16559 {
16560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16561 {
16562 return qe_invalid;
16563 }
16564
16565 23152640 }
16566 }
16567
16568
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16569 {
16570
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16571 {
16572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16573 {
16574 return qe_invalid;
16575 }
16576 23152640 }
16577
16578
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16579 {
16580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16581 {
16582 return qe_invalid;
16583 }
16584 23152640 }
16585 180880 }
16586
16587
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16588 {
16589 if(!p_getc(&padding,f,true))
16590 {
16591 return qe_invalid;
16592 }
16593 }
16594
16595 187744 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16596
16597
2/2
✓ Branch 0 taken 33042944 times.
✓ Branch 1 taken 187744 times.
33230688 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16598 {
16599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33042944 times.
33042944 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16600 {
16601 return qe_invalid;
16602 }
16603 33042944 }
16604
16605
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16606 {
16607 if(!p_getc(&padding,f,true))
16608 {
16609 return qe_invalid;
16610 }
16611
16612 if(!p_getc(&padding,f,true))
16613 {
16614 return qe_invalid;
16615 }
16616 }
16617
16618
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16619 {
16620
2/2
✓ Branch 0 taken 31834880 times.
✓ Branch 1 taken 180880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16621 {
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16623 {
16624 return qe_invalid;
16625 }
16626
16627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31834880 if((Header->zelda_version == 0x192)&&(Header->build<24))
16628 {
16629 if(!p_getc(&tempbyte,f,true))
16630 {
16631 return qe_invalid;
16632 }
16633
16634 if(!p_getc(&tempbyte,f,true))
16635 {
16636 return qe_invalid;
16637 }
16638
16639 if(!p_getc(&tempbyte,f,true))
16640 {
16641 return qe_invalid;
16642 }
16643 }
16644 31834880 }
16645 180880 }
16646
16647
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16648 {
16649
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 31834880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16650 {
16651
16652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16653 {
16654 return qe_invalid;
16655 }
16656 31834880 }
16657 180880 }
16658
16659
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16660 {
16661 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16662 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16663 6864 }
16664
16665
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16666 {
16667 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16668 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16669 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16670 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16671 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16672 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16673 6864 }
16674
16675
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16676 {
16677
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16678 {
16679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16680 {
16681 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16682 {
16683 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16684 }
16685 }
16686 else
16687 {
16688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16689 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16690 {
16691 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16692 1208064 }
16693
16694 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16695 }
16696
16697 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16698 1208064 }
16699 6864 }
16700
16701 /*if(version>12)
16702 {
16703 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16704 {
16705 return qe_invalid;
16706 }
16707 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16708 {
16709 return qe_invalid;
16710 }
16711 }*/
16712
16713
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>4)
16714 {
16715
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16716 {
16717 return qe_invalid;
16718 }
16719 153000 }
16720 else
16721 {
16722 34744 temp_mapscr->screen_midi = -1;
16723 }
16724
16725
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>=17)
16726 {
16727
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16728 {
16729 return qe_invalid;
16730 }
16731 153000 }
16732 else
16733 {
16734 34744 temp_mapscr->lens_layer = llNORMAL;
16735 }
16736
16737
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version>6)
16738 {
16739 dword bits;
16740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_igetl(&bits,f,true))
16741 {
16742 return qe_invalid;
16743 }
16744
16745 int32_t m;
16746 float tempfloat;
16747 word tempw;
16748 153000 temp_mapscr->ffcCountMarkDirty();
16749
16750
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 4896000 times.
5049000 for(m=0; m<32; m++)
16751 {
16752 4896000 ffcdata& tempffc = temp_mapscr->ffcs[m];
16753 4896000 tempffc.clear();
16754
2/2
✓ Branch 0 taken 4873014 times.
✓ Branch 1 taken 22986 times.
4896000 if((bits>>m)&1)
16755 {
16756
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetw(&tempw,f,true))
16757 {
16758 return qe_invalid;
16759 }
16760 22986 tempffc.setData(tempw);
16761
16762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.cset),f,true))
16763 {
16764 return qe_invalid;
16765 }
16766
16767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.delay),f,true))
16768 {
16769 return qe_invalid;
16770 }
16771
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(version < 9)
16773 {
16774 if(!p_igetf(&tempfloat,f,true))
16775 {
16776 return qe_invalid;
16777 }
16778
16779 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16780
16781 if(!p_igetf(&tempfloat,f,true))
16782 {
16783 return qe_invalid;
16784 }
16785
16786 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16787
16788 if(!p_igetf(&tempfloat,f,true))
16789 {
16790 return qe_invalid;
16791 }
16792
16793 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16794
16795 if(!p_igetf(&tempfloat,f,true))
16796 {
16797 return qe_invalid;
16798 }
16799
16800 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16801
16802 if(!p_igetf(&tempfloat,f,true))
16803 {
16804 return qe_invalid;
16805 }
16806
16807 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16808
16809 if(!p_igetf(&tempfloat,f,true))
16810 {
16811 return qe_invalid;
16812 }
16813
16814 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16815 }
16816 else
16817 {
16818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.x),f,true))
16819 {
16820 return qe_invalid;
16821 }
16822
16823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.y),f,true))
16824 {
16825 return qe_invalid;
16826 }
16827
16828
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetzf(&(tempffc.vx),f,true))
16829 {
16830 return qe_invalid;
16831 }
16832
16833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.vy),f,true))
16834 {
16835 return qe_invalid;
16836 }
16837
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ax),f,true))
16839 {
16840 return qe_invalid;
16841 }
16842
16843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ay),f,true))
16844 {
16845 return qe_invalid;
16846 }
16847 }
16848
16849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.link),f,true))
16850 {
16851 return qe_invalid;
16852 }
16853
16854
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>7)
16855 {
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16857 {
16858 return qe_invalid;
16859 }
16860
16861 22986 tempffc.hxsz = (tempbyte&0x3F)+1;
16862 22986 tempffc.txsz = (tempbyte>>6)+1;
16863
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16865 {
16866 return qe_invalid;
16867 }
16868
16869 22986 tempffc.hysz = (tempbyte&0x3F)+1;
16870 22986 tempffc.tysz = (tempbyte>>6)+1;
16871
16872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.flags),f,true))
16873 {
16874 return qe_invalid;
16875 }
16876 22986 }
16877 else
16878 {
16879 tempffc.hxsz=16;
16880 tempffc.hysz=16;
16881 tempffc.txsz=1;
16882 tempffc.tysz=1;
16883 tempffc.flags=0;
16884 }
16885
16886 22986 tempffc.updateSolid();
16887
16888
16889
4/6
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20966 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20966 times.
22986 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16890 {
16891 tempffc.flags|=ffIGNOREHOLDUP;
16892 }
16893
16894
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>9)
16895 {
16896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.script),f,true))
16897 {
16898 return qe_invalid;
16899 }
16900 22986 }
16901 else
16902 {
16903 tempffc.script=0;
16904 }
16905
16906
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>10)
16907 {
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[0]),f,true))
16909 {
16910 return qe_invalid;
16911 }
16912
16913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[1]),f,true))
16914 {
16915 return qe_invalid;
16916 }
16917
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[2]),f,true))
16919 {
16920 return qe_invalid;
16921 }
16922
16923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[3]),f,true))
16924 {
16925 return qe_invalid;
16926 }
16927
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[4]),f,true))
16929 {
16930 return qe_invalid;
16931 }
16932
16933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[5]),f,true))
16934 {
16935 return qe_invalid;
16936 }
16937
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[6]),f,true))
16939 {
16940 return qe_invalid;
16941 }
16942
16943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[7]),f,true))
16944 {
16945 return qe_invalid;
16946 }
16947
16948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16949 {
16950 return qe_invalid;
16951 }
16952
16953 22986 tempffc.inita[0]=tempbyte*10000;
16954
16955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16956 {
16957 return qe_invalid;
16958 }
16959
16960 22986 tempffc.inita[1]=tempbyte*10000;
16961 22986 }
16962 else
16963 {
16964 tempffc.inita[0] = 10000;
16965 tempffc.inita[1] = 10000;
16966 }
16967
16968 22986 tempffc.initialized = false;
16969
16970
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version <= 11)
16971 {
16972 fixffcs=true;
16973 }
16974 22986 }
16975 4896000 }
16976
16977 153000 }
16978
16979 //add in the new whistle flags
16980
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version<13)
16981 {
16982
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
16983 {
16984 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16985 12 }
16986 34744 }
16987
16988 // for(int32_t m=0; m<32; m++)
16989 // {
16990 // // ffcScriptData used to be part of mapscr, and this was handled just above
16991 // ffcScriptData[m].a[0] = 10000;
16992 // ffcScriptData[m].a[1] = 10000;
16993 // }
16994
16995 //2.55 starts here
16996
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 19 && Header->zelda_version > 0x253 )
16997 {
16998
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16999 {
17000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17001 {
17002 return qe_invalid;
17003 }
17004 137360 }
17005
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17006 {
17007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17008 {
17009 return qe_invalid;
17010 }
17011 137360 }
17012
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17013 {
17014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17015 {
17016 return qe_invalid;
17017 }
17018 137360 }
17019
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17020 {
17021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17022 {
17023 return qe_invalid;
17024 }
17025 137360 }
17026 13736 }
17027
3/4
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 174008 times.
187744 if ( version < 19 && Header->zelda_version > 0x253 )
17028 {
17029 for ( int32_t q = 0; q < 10; q++ )
17030 {
17031 temp_mapscr->npcstrings[q] = 0;
17032 temp_mapscr->new_items[q] = 0;
17033 temp_mapscr->new_item_x[q] = 0;
17034 temp_mapscr->new_item_y[q] = 0;
17035 }
17036 }
17037
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 20 && Header->zelda_version > 0x253 )
17038 {
17039
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17040 {
17041 return qe_invalid;
17042 }
17043
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17044 {
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17046 {
17047 return qe_invalid;
17048 }
17049 109888 }
17050 13736 }
17051
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
187744 if ( version < 20 )
17052 {
17053 174008 temp_mapscr->script = 0;
17054
2/2
✓ Branch 0 taken 1392064 times.
✓ Branch 1 taken 174008 times.
1566072 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17055 174008 }
17056
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 21 && Header->zelda_version > 0x253 )
17057 {
17058
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17059 {
17060 return qe_invalid;
17061 }
17062 13736 }
17063
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 21 )
17064 {
17065 174008 temp_mapscr->preloadscript = 0;
17066 174008 }
17067 //all builds with version > 20 need this. -Z
17068 187744 temp_mapscr->ffcswaitdraw = 0;
17069
17070
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17071 {
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17073 {
17074 return qe_invalid;
17075 }
17076
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17077 {
17078 return qe_invalid;
17079 }
17080 13736 }
17081
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 22 )
17082 {
17083 174008 temp_mapscr->hidelayers = 0;
17084 174008 temp_mapscr->hidescriptlayers = 0;
17085 174008 }
17086
17087 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17088 //May be any version before 2.11. -Z
17089 /* --not the roar, the HIT SFX
17090 if ( Header->zelda_version <= 0x210 )
17091 {
17092 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17093 {
17094 temp_mapscr->bosssfx = WAV_ROAR;
17095 }
17096 }
17097 */
17098
17099 187744 return 0;
17100 187744 }
17101 200256 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17102 {
17103
2/2
✓ Branch 0 taken 187744 times.
✓ Branch 1 taken 12512 times.
200256 if(version < 23)
17104 {
17105 187744 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17106
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(ret) return ret;
17107 187744 }
17108 else
17109 {
17110
1/2
✓ Branch 0 taken 12512 times.
✗ Branch 1 not taken.
12512 if(!p_getc(&(temp_mapscr->valid),f,true))
17111 return qe_invalid;
17112
2/2
✓ Branch 0 taken 5245 times.
✓ Branch 1 taken 7267 times.
12512 if(!(temp_mapscr->valid & mVALID))
17113 7267 return 0; //Empty screen
17114 uint32_t scr_has_flags;
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5245 times.
5245 if(!p_igetl(&scr_has_flags,f,true))
17116 return qe_invalid;
17117
17118
2/2
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 45 times.
5245 if(scr_has_flags & SCRHAS_ROOMDATA)
17119 {
17120
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
17123 return qe_invalid;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
17125 return qe_invalid;
17126
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17127 return qe_invalid;
17128 45 }
17129
2/2
✓ Branch 0 taken 5164 times.
✓ Branch 1 taken 81 times.
5245 if(scr_has_flags & SCRHAS_ITEM)
17130 {
17131
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
17132 return qe_invalid;
17133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17134 return qe_invalid;
17135
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
17136 return qe_invalid;
17137
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
17138 return qe_invalid;
17139 81 }
17140
2/2
✓ Branch 0 taken 4953 times.
✓ Branch 1 taken 292 times.
5245 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17141 {
17142
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17143 return qe_invalid;
17144 292 }
17145
2/2
✓ Branch 0 taken 5047 times.
✓ Branch 1 taken 198 times.
5245 if(scr_has_flags & SCRHAS_TWARP)
17146 {
17147
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17148 {
17149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17150 return qe_invalid;
17151 792 }
17152
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17155 return qe_invalid;
17156 792 }
17157
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17158 {
17159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17160 return qe_invalid;
17161 792 }
17162
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17163 return qe_invalid;
17164 198 }
17165
2/2
✓ Branch 0 taken 5127 times.
✓ Branch 1 taken 118 times.
5245 if(scr_has_flags & SCRHAS_SWARP)
17166 {
17167
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17168 {
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17170 return qe_invalid;
17171 472 }
17172
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17173 {
17174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17175 return qe_invalid;
17176 472 }
17177
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17178 {
17179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17180 return qe_invalid;
17181 472 }
17182
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17183 return qe_invalid;
17184
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17185 return qe_invalid;
17186 118 }
17187
2/2
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 295 times.
5245 if(scr_has_flags & SCRHAS_WARPRET)
17188 {
17189
2/2
✓ Branch 0 taken 1180 times.
✓ Branch 1 taken 295 times.
1475 for(int32_t i=0; i<4; i++)
17190 {
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1180 times.
1180 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17192 return qe_invalid;
17193 1180 }
17194
2/2
✓ Branch 0 taken 1180 times.
✓ Branch 1 taken 295 times.
1475 for(int32_t i=0; i<4; i++)
17195 {
17196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1180 times.
1180 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17197 return qe_invalid;
17198 1180 }
17199
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17200 return qe_invalid;
17201
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17202 return qe_invalid;
17203 295 }
17204
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 4213 times.
5245 if(scr_has_flags & SCRHAS_LAYERS)
17205 {
17206
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17207 {
17208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17209 return qe_invalid;
17210 6192 }
17211
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17212 {
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17214 return qe_invalid;
17215 6192 }
17216
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17217 {
17218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17219 return qe_invalid;
17220 6192 }
17221
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17222 return qe_invalid;
17223
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17224 return qe_invalid;
17225 1032 }
17226 else
17227 {
17228
2/2
✓ Branch 0 taken 25278 times.
✓ Branch 1 taken 4213 times.
29491 for(int32_t k=0; k<6; k++)
17229 {
17230 25278 temp_mapscr->layeropacity[k] = 255;
17231 25278 }
17232 }
17233
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(scr_has_flags & SCRHAS_MAZE)
17234 {
17235 for(int32_t k=0; k<4; k++)
17236 {
17237 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17238 return qe_invalid;
17239 }
17240 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17241 return qe_invalid;
17242 }
17243
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 100 times.
5245 if(scr_has_flags & SCRHAS_D_S_U)
17244 {
17245
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17246 return qe_invalid;
17247
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 100 times.
500 for(int32_t k=0; k<4; k++)
17248 {
17249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 400 times.
400 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17250 return qe_invalid;
17251 400 }
17252
17253
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->stairx),f,true))
17254 return qe_invalid;
17255
17256
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->stairy),f,true))
17257 return qe_invalid;
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17259 return qe_invalid;
17260
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->undercset),f,true))
17261 return qe_invalid;
17262 100 }
17263
2/2
✓ Branch 0 taken 4886 times.
✓ Branch 1 taken 359 times.
5245 if(scr_has_flags & SCRHAS_FLAGS)
17264 {
17265
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags),f,true))
17266 return qe_invalid;
17267
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags2),f,true))
17268 return qe_invalid;
17269
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags3),f,true))
17270 return qe_invalid;
17271
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags4),f,true))
17272 return qe_invalid;
17273
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags5),f,true))
17274 return qe_invalid;
17275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
359 if(!p_getc(&(temp_mapscr->flags6),f,true))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags7),f,true))
17278 return qe_invalid;
17279
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags8),f,true))
17280 return qe_invalid;
17281
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags9),f,true))
17282 return qe_invalid;
17283
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags10),f,true))
17284 return qe_invalid;
17285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
359 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17286 return qe_invalid;
17287 359 }
17288
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 317 times.
5245 if(scr_has_flags & SCRHAS_ENEMY)
17289 {
17290
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 317 times.
3487 for(int32_t k=0; k<10; k++)
17291 {
17292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3170 times.
3170 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17293 return qe_invalid;
17294
1/2
✓ Branch 0 taken 3170 times.
✗ Branch 1 not taken.
3170 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17295 temp_mapscr->enemy[k] = 0;
17296 3170 }
17297
1/2
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
317 if(!p_getc(&(temp_mapscr->pattern),f,true))
17298 return qe_invalid;
17299 317 }
17300
2/2
✓ Branch 0 taken 5214 times.
✓ Branch 1 taken 31 times.
5245 if(scr_has_flags & SCRHAS_CARRY)
17301 {
17302
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17303 return qe_invalid;
17304
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17305 return qe_invalid;
17306
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17307 return qe_invalid;
17308
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17309 return qe_invalid;
17310 31 }
17311
2/2
✓ Branch 0 taken 5221 times.
✓ Branch 1 taken 24 times.
5245 if(scr_has_flags & SCRHAS_SCRIPT)
17312 {
17313
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17314 return qe_invalid;
17315
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17316 return qe_invalid;
17317
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17318 {
17319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17320 return qe_invalid;
17321 192 }
17322 24 }
17323
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(scr_has_flags & SCRHAS_UNUSED)
17324 {
17325 for ( int32_t q = 0; q < 10; q++ )
17326 {
17327 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17328 return qe_invalid;
17329 }
17330 for ( int32_t q = 0; q < 10; q++ )
17331 {
17332 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17333 return qe_invalid;
17334 }
17335 for ( int32_t q = 0; q < 10; q++ )
17336 {
17337 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17338 return qe_invalid;
17339 }
17340 for ( int32_t q = 0; q < 10; q++ )
17341 {
17342 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17343 return qe_invalid;
17344 }
17345 }
17346
2/2
✓ Branch 0 taken 4896 times.
✓ Branch 1 taken 349 times.
5245 if(scr_has_flags & SCRHAS_SECRETS)
17347 {
17348
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17349 {
17350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17351 return qe_invalid;
17352 44672 }
17353
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17354 {
17355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17356 return qe_invalid;
17357 44672 }
17358
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17359 {
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17361 return qe_invalid;
17362 44672 }
17363 349 }
17364
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2386 times.
5245 if(scr_has_flags & SCRHAS_COMBOFLAG)
17365 {
17366
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17367 {
17368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17369 return qe_invalid;
17370 419936 }
17371
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17372 {
17373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17374 return qe_invalid;
17375 419936 }
17376
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17377 {
17378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17379 return qe_invalid;
17380 419936 }
17381 2386 }
17382
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(scr_has_flags & SCRHAS_MISC)
17383 {
17384
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_igetw(&(temp_mapscr->color),f,true))
17385 return qe_invalid;
17386
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17387 return qe_invalid;
17388
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17389 return qe_invalid;
17390
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17391 return qe_invalid;
17392
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17393 return qe_invalid;
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5245 times.
5245 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17395 return qe_invalid;
17396
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17397 return qe_invalid;
17398
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17399 return qe_invalid;
17400
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17401 return qe_invalid;
17402 5245 }
17403 else
17404 {
17405 temp_mapscr->screen_midi = -1;
17406 temp_mapscr->csensitive = 1;
17407 }
17408 //FFC
17409 5245 bool old_ff = version < 25;
17410 5245 dword bits = 0;
17411 5245 word numffc = 32;
17412
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 5223 times.
5245 if(old_ff)
17413 {
17414
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&bits,f,true))
17415 return qe_invalid;
17416 22 }
17417 else
17418 {
17419
1/2
✓ Branch 0 taken 5223 times.
✗ Branch 1 not taken.
5223 if(!p_igetw(&numffc,f,true))
17420 return qe_invalid;
17421 }
17422 byte tempbyte;
17423 word tempw;
17424
4/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
5245 static ffcdata nil_ffc;
17425 5245 temp_mapscr->ffcCountMarkDirty();
17426
2/2
✓ Branch 0 taken 5245 times.
✓ Branch 1 taken 6851 times.
12096 for(word m = 0; m < numffc; ++m)
17427 {
17428
1/2
✓ Branch 0 taken 6851 times.
✗ Branch 1 not taken.
6851 ffcdata& tempffc = (m < MAXFFCS)
17429 6851 ? temp_mapscr->ffcs[m]
17430 : nil_ffc; //sanity
17431 6851 tempffc.clear();
17432
3/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 6147 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
6851 if(old_ff && !(bits & (1<<m))) continue;
17433
17434
1/2
✓ Branch 0 taken 6147 times.
✗ Branch 1 not taken.
6147 if(!p_igetw(&tempw,f,true))
17435 return qe_invalid;
17436
3/4
✓ Branch 0 taken 6147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5182 times.
6147 if(!old_ff && !tempw) //empty ffc, nothing more to load
17437 5182 continue;
17438 965 tempffc.setData(tempw);
17439
17440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17441 return qe_invalid;
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17443 return qe_invalid;
17444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17445 return qe_invalid;
17446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17447 return qe_invalid;
17448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17449 return qe_invalid;
17450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17451 return qe_invalid;
17452
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17453 return qe_invalid;
17454
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17455 return qe_invalid;
17456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17457 return qe_invalid;
17458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17459 {
17460 if(!p_getc(&tempbyte,f,true))
17461 return qe_invalid;
17462 tempffc.hxsz = (tempbyte&0x3F)+1;
17463 tempffc.txsz = (tempbyte>>6)+1;
17464 if(!p_getc(&tempbyte,f,true))
17465 return qe_invalid;
17466 tempffc.hysz = (tempbyte&0x3F)+1;
17467 tempffc.tysz = (tempbyte>>6)+1;
17468 }
17469 else
17470 {
17471
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17472 return qe_invalid;
17473
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17474 return qe_invalid;
17475
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17476 return qe_invalid;
17477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17478 return qe_invalid;
17479 }
17480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17481 return qe_invalid;
17482 965 tempffc.updateSolid();
17483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17484 return qe_invalid;
17485
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17486 {
17487
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17488 return qe_invalid;
17489 7720 }
17490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17491 return qe_invalid;
17492 965 tempffc.inita[0]=tempbyte*10000;
17493
17494
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17495 return qe_invalid;
17496 965 tempffc.inita[1]=tempbyte*10000;
17497
17498 965 tempffc.initialized = false;
17499 965 }
17500
2/2
✓ Branch 0 taken 664509 times.
✓ Branch 1 taken 5245 times.
669754 for(word m = numffc; m < MAXFFCS; ++m)
17501 {
17502 664509 temp_mapscr->ffcs[m].clear();
17503 664509 }
17504 //END FFC
17505 }
17506 192989 return 0;
17507 200256 }
17508
17509
17510 108 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17511 {
17512 108 int32_t scr=0;
17513
17514 108 word version=0;
17515 dword dummy;
17516 int32_t screens_to_read;
17517
17518 108 mapscr temp_mapscr;
17519 zcmap temp_map;
17520 word temp_map_count;
17521 dword section_size;
17522
17523
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17524 {
17525 4 screens_to_read=MAPSCRS192b136;
17526 4 }
17527 else
17528 {
17529 104 screens_to_read=MAPSCRS;
17530 }
17531
17532
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version > 0x192)
17533 {
17534 //section version info
17535
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&version,f,true))
17536 {
17537 return qe_invalid;
17538 }
17539
17540 104 FFCore.quest_format[vMaps] = version;
17541
17542 //al_trace("Maps version %d\n", version);
17543
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
17544 {
17545 return qe_invalid;
17546 }
17547
17548 //section size
17549
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&section_size,f,true))
17550 {
17551 return qe_invalid;
17552 }
17553
17554 //finally... section data
17555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_igetw(&temp_map_count,f,true))
17556 {
17557 return 5;
17558 }
17559 104 }
17560 else
17561 {
17562 4 temp_map_count=map_count;
17563 }
17564
17565
17566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
17567 {
17568 108 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17569 108 TheMaps.resize(_mapsSize);
17570
17571
2/2
✓ Branch 0 taken 201416 times.
✓ Branch 1 taken 108 times.
201524 for(int32_t i(0); i<_mapsSize; i++)
17572 201416 TheMaps[i].zero_memory();
17573
17574 // Used to be done for each screen
17575
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 108 times.
13932 for(int32_t i=0; i<MAXFFCS; i++)
17576 {
17577 13824 ffcScriptData[i].a[0] = 10000;
17578 13824 ffcScriptData[i].a[1] = 10000;
17579 13824 }
17580
17581 108 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17582 108 }
17583
17584 108 temp_mapscr.zero_memory();
17585
17586 108 memset(&temp_map, 0, sizeof(zcmap));
17587 108 temp_map.scrResWidth = 256;
17588 108 temp_map.scrResHeight = 224;
17589 108 temp_map.tileWidth = 16;
17590 108 temp_map.tileHeight = 11;
17591 108 temp_map.viewWidth = 256;
17592 108 temp_map.viewHeight = 176;
17593 108 temp_map.viewX = 0;
17594 108 temp_map.viewY = 64;
17595 108 temp_map.subaWidth = 256;
17596 108 temp_map.subaHeight = 168;
17597 108 temp_map.subaTrans = false;
17598 108 temp_map.subpWidth = 256;
17599 108 temp_map.subpHeight = 56;
17600 108 temp_map.subpTrans = false;
17601
4/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 1481 times.
✓ Branch 2 taken 1481 times.
✓ Branch 3 taken 108 times.
1589 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17602 {
17603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
1481 if(keepdata==true) //!TODO Trim fully
17604 {
17605 1481 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17606 1481 }
17607 1481 byte valid=1;
17608
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 99 times.
1481 if(version > 22)
17609 {
17610
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&valid,f,true))
17611 return qe_invalid;
17612 99 }
17613
2/2
✓ Branch 0 taken 201208 times.
✓ Branch 1 taken 1481 times.
202689 for(int32_t j=0; j<screens_to_read; j++)
17614 {
17615 201208 scr=i*MAPSCRS+j;
17616 201208 clear_screen(&temp_mapscr);
17617
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 200256 times.
201208 if(valid)
17618 200256 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17619
17620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201208 times.
201208 if(keepdata==true)
17621 {
17622 201208 TheMaps[scr] = temp_mapscr;
17623 201208 }
17624 201208 }
17625
17626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
1481 if(keepdata==true)
17627 {
17628
3/6
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1429 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1481 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17629 {
17630 52 int32_t index = (i*MAPSCRS+132);
17631
17632 52 TheMaps[index]=TheMaps[index-1];
17633
17634 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17635 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17636 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17637
17638
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17639 {
17640 156 scr=i*MAPSCRS+j;
17641
17642 156 TheMaps[scr].zero_memory();
17643 156 TheMaps[scr].valid = mVERSION;
17644 156 TheMaps[scr].screen_midi = -1;
17645 156 TheMaps[scr].csensitive = 1;
17646 156 }
17647 52 }
17648
17649
3/6
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1429 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1481 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17650 {
17651
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17652 {
17653 7072 scr=i*MAPSCRS+j;
17654 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17655
17656
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17657 {
17658 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17659 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17660 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17661 905216 }
17662 7072 }
17663 52 }
17664 1481 }
17665 1481 }
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
17667 {
17668 108 map_count = temp_map_count;
17669 108 }
17670 108 clear_screen(&temp_mapscr);
17671 108 return 0;
17672 108 }
17673
17674
17675 87 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17676 {
17677 87 reset_combo_animations();
17678 87 reset_combo_animations2();
17679
17680 87 init_combo_classes();
17681
17682 // combos
17683 87 word combos_used=0;
17684 int32_t dummy;
17685 byte padding;
17686 87 newcombo temp_combo;
17687 //word section_cversion=0;
17688
17689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata==true)
17690 {
17691
2/2
✓ Branch 0 taken 5679360 times.
✓ Branch 1 taken 87 times.
5679447 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17692 5679360 combobuf[q].clear();
17693 87 }
17694
17695 // if(version > 0x192)
17696 // {
17697 // //section version info
17698 // if(!p_igetw(&section_version,f,true))
17699 // {
17700 // return qe_invalid;
17701 // }
17702
17703 // FFCore.quest_format[vCombos] = section_version;
17704
17705 // //al_trace("Combos version %d\n", section_version);
17706 // if(!p_igetw(&section_cversion,f,true))
17707 // {
17708 // return qe_invalid;
17709 // }
17710
17711 // //section size
17712 // if(!p_igetl(&dummy,f,true))
17713 // {
17714 // return qe_invalid;
17715 // }
17716 // }
17717
17718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(version < 0x174)
17719 {
17720 combos_used=1024;
17721 }
17722
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 83 times.
87 else if(version < 0x191)
17723 {
17724 4 combos_used=2048;
17725 4 }
17726 else
17727 {
17728
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&combos_used,f,true))
17729 {
17730 return qe_invalid;
17731 }
17732 }
17733
17734 //finally... section data
17735
2/2
✓ Branch 0 taken 516329 times.
✓ Branch 1 taken 87 times.
516416 for(int32_t i=0; i<combos_used; i++)
17736 {
17737 516329 temp_combo.clear();
17738
17739
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if ( section_version >= 11 )
17740 {
17741
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17742 {
17743 return qe_invalid;
17744 }
17745 68884 }
17746 else
17747 {
17748
1/2
✓ Branch 0 taken 447445 times.
✗ Branch 1 not taken.
447445 if(!p_igetw(&temp_combo.tile,f,true))
17749 {
17750 return qe_invalid;
17751 }
17752 }
17753 516329 temp_combo.o_tile = temp_combo.tile;
17754
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 if(!p_getc(&temp_combo.flip,f,true))
17755 {
17756 return qe_invalid;
17757 }
17758
17759
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 if(!p_getc(&temp_combo.walk,f,true))
17760 {
17761 return qe_invalid;
17762 }
17763
17764
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 if(!p_getc(&temp_combo.type,f,true))
17765 {
17766 return qe_invalid;
17767 }
17768
17769
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 if(!p_getc(&temp_combo.csets,f,true))
17770 {
17771 return qe_invalid;
17772 }
17773
17774
2/2
✓ Branch 0 taken 508137 times.
✓ Branch 1 taken 8192 times.
516329 if(version < 0x193)
17775 {
17776
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17777 return qe_invalid;
17778
17779
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17780 return qe_invalid;
17781
17782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17783 {
17784
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17785 {
17786 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17787 {
17788 if(!p_getc(&padding,f,true))
17789 return qe_invalid;
17790 }
17791 }
17792 8192 }
17793 8192 }
17794
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 508137 times.
516329 if(version >= 0x192)
17795 {
17796
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(!p_getc(&temp_combo.frames,f,true))
17797 return qe_invalid;
17798
17799
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(!p_getc(&temp_combo.speed,f,true))
17800 return qe_invalid;
17801
17802
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(!p_igetw(&temp_combo.nextcombo,f,true))
17803 return qe_invalid;
17804
17805
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(!p_getc(&temp_combo.nextcset,f,true))
17806 return qe_invalid;
17807
17808 //Base flag
17809
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 399023 times.
508137 if(section_version>=3)
17810
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(!p_getc(&temp_combo.flag,f,true))
17811 return qe_invalid;
17812
17813
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 399023 times.
508137 if(section_version>=4)
17814 {
17815
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(!p_getc(&temp_combo.skipanim,f,true))
17816 return qe_invalid;
17817
17818
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(!p_igetw(&temp_combo.nexttimer,f,true))
17819 return qe_invalid;
17820 399023 }
17821
17822
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 399023 times.
508137 if(section_version>=5)
17823
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(!p_getc(&temp_combo.skipanimy,f,true))
17824 return qe_invalid;
17825
17826
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 399023 times.
508137 if(section_version>=6)
17827 {
17828
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(!p_getc(&temp_combo.animflags,f,true))
17829 return qe_invalid;
17830
17831
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(section_version == 6)
17832 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17833 399023 }
17834
17835
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=8) //combo Attributes[4] and userflags.
17836 {
17837
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17838
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17839 return qe_invalid;
17840
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17841 return qe_invalid;
17842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(section_version >= 20)
17843
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17844 return qe_invalid;
17845 68884 }
17846
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=10) //combo trigger flags
17847 {
17848
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17849
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17850 return qe_invalid;
17851 68884 }
17852
1/2
✓ Branch 0 taken 439253 times.
✗ Branch 1 not taken.
439253 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17853 {
17854 for ( int32_t q = 0; q < 2; q++ )
17855 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17856 return qe_invalid;
17857 }
17858
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version >= 9)
17859
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17860 return qe_invalid;
17861
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version >= 22)
17862
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17863 return qe_invalid;
17864
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 24)
17865 {
17866 if(!p_getc(&temp_combo.triggeritem,f,true))
17867 return qe_invalid;
17868 if(!p_getc(&temp_combo.trigtimer,f,true))
17869 return qe_invalid;
17870 }
17871
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 25)
17872 if(!p_getc(&temp_combo.trigsfx,f,true))
17873 return qe_invalid;
17874
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 27)
17875 if(!p_igetl(&temp_combo.trigchange,f,true))
17876 return qe_invalid;
17877
17878
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 29)
17879 {
17880 if(!p_igetw(&temp_combo.trigprox,f,true))
17881 return qe_invalid;
17882 if(!p_getc(&temp_combo.trigctr,f,true))
17883 return qe_invalid;
17884 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17885 return qe_invalid;
17886 }
17887
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 30)
17888 if(!p_getc(&temp_combo.triglbeam,f,true))
17889 return qe_invalid;
17890
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 31)
17891 {
17892 if(!p_getc(&temp_combo.trigcschange,f,true))
17893 return qe_invalid;
17894 if(!p_igetw(&temp_combo.spawnitem,f,true))
17895 return qe_invalid;
17896 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17897 return qe_invalid;
17898 if(!p_getc(&temp_combo.exstate,f,true))
17899 return qe_invalid;
17900 if(!p_igetl(&temp_combo.spawnip,f,true))
17901 return qe_invalid;
17902 if(!p_getc(&temp_combo.trigcopycat,f,true))
17903 return qe_invalid;
17904 }
17905
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(section_version >= 32)
17906 if(!p_getc(&temp_combo.trigcooldown,f,true))
17907 return qe_invalid;
17908
17909
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=12) //combo label
17910
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17911
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17912 68884 return qe_invalid;
17913
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=13) //attribytes[4]
17914
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17915
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17916 68884 return qe_invalid;
17917 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17918 * This fixes a poor implementation of a ->next flag bug thing.
17919 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17920 * there was a version bump a few weeks before a change that broke stuff.
17921 */
17922
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
508137 if (section_version >= 13 && section_version < 21)
17923 {
17924 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17925 }
17926 //combo scripts
17927
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=14)
17928 {
17929
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17930 return qe_invalid;
17931
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17932
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17933 return qe_invalid;
17934 68884 }
17935 //al_trace("Read combo script data\n");
17936
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=15)
17937 {
17938
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17939
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17940
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17942 68884 }
17943
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=17) //attribytes[4]
17944 {
17945
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17946
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17947 return qe_invalid;
17948
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17949
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17950 return qe_invalid;
17951 68884 }
17952
17953
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(version < 0x193)
17954 for(int32_t q=0; q<11; q++)
17955 if(!p_getc(&dummy,f,true))
17956 return qe_invalid;
17957 508137 }
17958
17959 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17960
3/6
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399023 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516329 if((version < 0x211)||((version == 0x211)&&(build<7)))
17961 {
17962
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17963 {
17964
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17965 {
17966 case 130:
17967 temp_combo.tile = 132;
17968 break;
17969
17970 case 131:
17971 temp_combo.tile = 133;
17972 break;
17973
17974 case 132:
17975 temp_combo.tile = 130;
17976 break;
17977
17978 case 133:
17979 temp_combo.tile = 131;
17980 break;
17981 }
17982 8192 }
17983 117306 }
17984
17985
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 15)
17986 447445 temp_combo.o_tile = temp_combo.tile;
17987
17988
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version<18) //upper bits for .walk
17989 447445 temp_combo.walk |= 0xF0;
17990
17991
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 19)
17992
2/2
✓ Branch 0 taken 1789780 times.
✓ Branch 1 taken 447445 times.
2237225 for(int32_t q = 0; q < 4; ++q)
17993 2237225 temp_combo.attributes[q] *= 10000L;
17994
17995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 23)
17996 {
17997
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 515945 times.
516329 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17998 {
17999 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18000 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18001 case cTRIGGERGENERIC: case cCSWITCH:
18002 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
18003 384 }
18004 516329 }
18005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 25)
18006 {
18007
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 513681 times.
516329 switch(temp_combo.type)
18008 {
18009 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
2648 if(!(temp_combo.usrflags & cflag3))
18011 2648 temp_combo.attribytes[3] = WAV_DOOR;
18012 2648 temp_combo.usrflags &= ~cflag3;
18013 2648 break;
18014 }
18015 516329 }
18016
18017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 26)
18018
2/2
✓ Branch 0 taken 515799 times.
✓ Branch 1 taken 530 times.
516859 if(temp_combo.type == cARMOS)
18019
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if(temp_combo.usrflags & cflag1)
18020 temp_combo.usrflags |= cflag3;
18021
18022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 27)
18023 {
18024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
18025 temp_combo.trigchange = 1;
18026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
18027 temp_combo.trigchange = -1;
18028 516329 else temp_combo.trigchange = 0;
18029 516329 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
18030 516329 }
18031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 28)
18032 {
18033
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 514920 times.
516329 switch(temp_combo.type)
18034 {
18035 case cLOCKBLOCK: case cLOCKEDCHEST:
18036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1409 times.
1409 if(temp_combo.usrflags & cflag7)
18037 temp_combo.usrflags |= cflag8;
18038 1409 else temp_combo.usrflags &= ~cflag8;
18039 1409 temp_combo.usrflags &= ~cflag7;
18040 1409 break;
18041 }
18042
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 516260 times.
516329 switch(temp_combo.type)
18043 {
18044 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18045 69 temp_combo.attrishorts[2] = -1;
18046 69 temp_combo.usrflags |= cflag7;
18047 69 break;
18048 }
18049 516329 }
18050
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 20)
18051 {
18052 447445 temp_combo.genflags = 0;
18053
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 429922 times.
447445 switch(temp_combo.type)
18054 {
18055 case cPUSH_WAIT: case cPUSH_HEAVY:
18056 case cPUSH_HW: case cL_STATUE:
18057 case cR_STATUE: case cPUSH_HEAVY2:
18058 case cPUSH_HW2: case cPOUND:
18059 case cC_STATUE: case cMIRROR:
18060 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18061 case cMAGICPRISM: case cMAGICPRISM4:
18062 case cMAGICSPONGE: case cEYEBALL_A:
18063 case cEYEBALL_B: case cEYEBALL_4:
18064 case cBUSH: case cFLOWERS:
18065 case cLOCKBLOCK: case cLOCKBLOCK2:
18066 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18067 case cCHEST: case cCHEST2:
18068 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18069 case cBOSSCHEST: case cBOSSCHEST2:
18070 case cBUSHNEXT: case cBUSHTOUCHY:
18071 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18072 case cSIGNPOST: case cCSWITCHBLOCK:
18073 case cTORCH: case cTRIGGERGENERIC:
18074
1/2
✓ Branch 0 taken 17523 times.
✗ Branch 1 not taken.
17523 if(temp_combo.usrflags & cflag16)
18075 {
18076 temp_combo.genflags |= cflag1;
18077 temp_combo.usrflags &= ~cflag16;
18078 }
18079 17523 break;
18080 }
18081 447445 }
18082
18083
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 516329 times.
516329 if(keepdata==true && i>=start_combo)
18084 {
18085 516329 combobuf[i] = temp_combo;
18086 516329 }
18087 516329 }
18088
18089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata==true)
18090 {
18091
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18092 {
18093
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18094 {
18095
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18096 {
18097 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18098 }
18099 261120 }
18100 4 }
18101
18102 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18103
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
87 if(version == 0x210 && !is_zquest())
18104 {
18105
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18106
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18107 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18108 5 }
18109
18110
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 9 times.
87 if(section_version<7)
18111 {
18112
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18113 {
18114
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18115 {
18116 case cSLASH:
18117 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18118 61 break;
18119
18120 case cSLASHITEM:
18121 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18122 62 break;
18123
18124 case cBUSH:
18125 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18126 28 break;
18127
18128 case cFLOWERS:
18129 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18130 10 break;
18131
18132 case cTALLGRASS:
18133 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18134 10 break;
18135
18136 case cSLASHNEXT:
18137 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18138 break;
18139
18140 case cSLASHNEXTITEM:
18141 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18142 break;
18143
18144 case cBUSHNEXT:
18145 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18146 break;
18147 }
18148 587520 }
18149 9 }
18150
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 85 times.
87 if (section_version < 16)
18151 {
18152
2/2
✓ Branch 0 taken 5548800 times.
✓ Branch 1 taken 85 times.
5548885 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18153 {
18154
2/2
✓ Branch 0 taken 5543143 times.
✓ Branch 1 taken 5657 times.
5548800 if (combobuf[tmpcounter].type == cWATER)
18155 {
18156 5657 combobuf[tmpcounter].attributes[0] = 40000L;
18157 5657 }
18158 5548800 }
18159 85 }
18160
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 1 times.
87 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18161 {
18162 1 combobuf[0].walk = 0xF0;
18163 1 combobuf[0].type = 0;
18164 1 combobuf[0].flag = 0;
18165 1 }
18166 87 }
18167
18168 //Now for the new combo alias reset
18169
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
87 if(section_version<2 && keepdata)
18170 {
18171
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18172 {
18173 73728 combo_aliases[j].width = 0;
18174 73728 combo_aliases[j].height = 0;
18175 73728 combo_aliases[j].layermask = 0;
18176
18177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18178 {
18179
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].combos;
18180 73728 }
18181
18182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18183 {
18184
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].csets;
18185 73728 }
18186
18187 73728 combo_aliases[j].combos = new word[1];
18188 73728 combo_aliases[j].csets = new byte[1];
18189 73728 combo_aliases[j].combos[0] = 0;
18190 73728 combo_aliases[j].csets[0] = 0;
18191 73728 }
18192 9 }
18193
18194
18195 87 setup_combo_animations();
18196 87 setup_combo_animations2();
18197 87 return 0;
18198 87 }
18199 136622 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18200 {
18201 byte combo_has_flags;
18202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136622 times.
136622 if(!p_getc(&combo_has_flags,f,true))
18203 return qe_invalid;
18204
18205 136622 temp_combo.clear();
18206
2/2
✓ Branch 0 taken 88230 times.
✓ Branch 1 taken 48392 times.
136622 if(combo_has_flags)
18207 {
18208
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 48389 times.
48392 if(combo_has_flags&CHAS_BASIC)
18209 {
18210
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_igetl(&temp_combo.tile,f,true))
18211 {
18212 return qe_invalid;
18213 }
18214 48389 temp_combo.o_tile = temp_combo.tile;
18215
18216
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_getc(&temp_combo.flip,f,true))
18217 {
18218 return qe_invalid;
18219 }
18220
18221
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_getc(&temp_combo.walk,f,true))
18222 {
18223 return qe_invalid;
18224 }
18225
18226
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_getc(&temp_combo.type,f,true))
18227 {
18228 return qe_invalid;
18229 }
18230
18231
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_getc(&temp_combo.flag,f,true))
18232 {
18233 return qe_invalid;
18234 }
18235
18236
1/2
✓ Branch 0 taken 48389 times.
✗ Branch 1 not taken.
48389 if(!p_getc(&temp_combo.csets,f,true))
18237 {
18238 return qe_invalid;
18239 }
18240 48389 }
18241
2/2
✓ Branch 0 taken 48369 times.
✓ Branch 1 taken 23 times.
48392 if(combo_has_flags&CHAS_SCRIPT)
18242 {
18243
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 23 times.
276 for ( int32_t q = 0; q < 11; q++ )
18244 {
18245
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&temp_combo.label[q],f,true))
18246 {
18247 return qe_invalid;
18248 }
18249 253 }
18250
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18251
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18252 {
18253
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f,true))
18254 {
18255 return qe_invalid;
18256 }
18257 46 }
18258 23 }
18259
2/2
✓ Branch 0 taken 35065 times.
✓ Branch 1 taken 13327 times.
48392 if(combo_has_flags&CHAS_ANIM)
18260 {
18261
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.frames,f,true))
18262 {
18263 return qe_invalid;
18264 }
18265
18266
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.speed,f,true))
18267 {
18268 return qe_invalid;
18269 }
18270
18271
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_igetw(&temp_combo.nextcombo,f,true))
18272 {
18273 return qe_invalid;
18274 }
18275
18276
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.nextcset,f,true))
18277 {
18278 return qe_invalid;
18279 }
18280
18281
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.skipanim,f,true))
18282 {
18283 return qe_invalid;
18284 }
18285
18286
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.skipanimy,f,true))
18287 {
18288 return qe_invalid;
18289 }
18290
18291
1/2
✓ Branch 0 taken 13327 times.
✗ Branch 1 not taken.
13327 if(!p_getc(&temp_combo.animflags,f,true))
18292 {
18293 return qe_invalid;
18294 }
18295 13327 }
18296
2/2
✓ Branch 0 taken 44071 times.
✓ Branch 1 taken 4321 times.
48392 if(combo_has_flags&CHAS_ATTRIB)
18297 {
18298
2/2
✓ Branch 0 taken 17284 times.
✓ Branch 1 taken 4321 times.
21605 for ( int32_t q = 0; q < 4; q++ )
18299 {
18300
1/2
✓ Branch 0 taken 17284 times.
✗ Branch 1 not taken.
17284 if(!p_igetl(&temp_combo.attributes[q],f,true))
18301 {
18302 return qe_invalid;
18303 }
18304 17284 }
18305
2/2
✓ Branch 0 taken 34568 times.
✓ Branch 1 taken 4321 times.
38889 for ( int32_t q = 0; q < 8; q++ )
18306 {
18307
1/2
✓ Branch 0 taken 34568 times.
✗ Branch 1 not taken.
34568 if(!p_getc(&temp_combo.attribytes[q],f,true))
18308 {
18309 return qe_invalid;
18310 }
18311 34568 }
18312
2/2
✓ Branch 0 taken 34568 times.
✓ Branch 1 taken 4321 times.
38889 for ( int32_t q = 0; q < 8; q++ )
18313 {
18314
1/2
✓ Branch 0 taken 34568 times.
✗ Branch 1 not taken.
34568 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18315 {
18316 return qe_invalid;
18317 }
18318 34568 }
18319 4321 }
18320
2/2
✓ Branch 0 taken 46977 times.
✓ Branch 1 taken 1415 times.
48392 if(combo_has_flags&CHAS_FLAG)
18321 {
18322
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(!p_igetl(&temp_combo.usrflags,f,true))
18323 {
18324 return qe_invalid;
18325 }
18326
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(!p_igetw(&temp_combo.genflags,f,true))
18327 {
18328 return qe_invalid;
18329 }
18330 1415 }
18331
2/2
✓ Branch 0 taken 47972 times.
✓ Branch 1 taken 420 times.
48392 if(combo_has_flags&CHAS_TRIG)
18332 {
18333 420 int numtrigs = s_version < 36 ? 3 : 6;
18334
2/2
✓ Branch 0 taken 1950 times.
✓ Branch 1 taken 420 times.
2370 for ( int32_t q = 0; q < numtrigs; q++ )
18335 {
18336
1/2
✓ Branch 0 taken 1950 times.
✗ Branch 1 not taken.
1950 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18337 {
18338 return qe_invalid;
18339 }
18340 1950 }
18341
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18342 {
18343 return qe_invalid;
18344 }
18345
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.triggerbtn,f,true))
18346 {
18347 return qe_invalid;
18348 }
18349
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.triggeritem,f,true))
18350 {
18351 return qe_invalid;
18352 }
18353
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigtimer,f,true))
18354 {
18355 return qe_invalid;
18356 }
18357
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigsfx,f,true))
18358 {
18359 return qe_invalid;
18360 }
18361
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetl(&temp_combo.trigchange,f,true))
18362 {
18363 return qe_invalid;
18364 }
18365
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.trigprox,f,true))
18366 {
18367 return qe_invalid;
18368 }
18369
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigctr,f,true))
18370 {
18371 return qe_invalid;
18372 }
18373
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18374 {
18375 return qe_invalid;
18376 }
18377
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.triglbeam,f,true))
18378 {
18379 return qe_invalid;
18380 }
18381
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigcschange,f,true))
18382 {
18383 return qe_invalid;
18384 }
18385
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.spawnitem,f,true))
18386 {
18387 return qe_invalid;
18388 }
18389
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18390 {
18391 return qe_invalid;
18392 }
18393
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.exstate,f,true))
18394 {
18395 return qe_invalid;
18396 }
18397
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetl(&temp_combo.spawnip,f,true))
18398 {
18399 return qe_invalid;
18400 }
18401
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigcopycat,f,true))
18402 {
18403 return qe_invalid;
18404 }
18405
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.trigcooldown,f,true))
18406 {
18407 return qe_invalid;
18408 }
18409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
420 if(s_version >= 35)
18410 {
18411
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18412 {
18413 return qe_invalid;
18414 }
18415
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_getc(&temp_combo.prompt_cs,f,true))
18416 {
18417 return qe_invalid;
18418 }
18419
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.prompt_x,f,true))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!p_igetw(&temp_combo.prompt_y,f,true))
18424 {
18425 return qe_invalid;
18426 }
18427 420 }
18428
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 230 times.
420 if(s_version >= 36)
18429 {
18430
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 if(!p_getc(&temp_combo.trig_lstate,f,true))
18431 {
18432 return qe_invalid;
18433 }
18434
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 if(!p_getc(&temp_combo.trig_gstate,f,true))
18435 {
18436 return qe_invalid;
18437 }
18438
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18439 {
18440 return qe_invalid;
18441 }
18442 230 }
18443
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 230 times.
420 if(s_version >= 37)
18444 {
18445
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18446 {
18447 return qe_invalid;
18448 }
18449 230 }
18450
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 156 times.
420 if(s_version >= 38)
18451 {
18452
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(!p_getc(&temp_combo.trig_group,f,true))
18453 {
18454 return qe_invalid;
18455 }
18456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18457 {
18458 return qe_invalid;
18459 }
18460 156 }
18461 420 }
18462
2/2
✓ Branch 0 taken 48299 times.
✓ Branch 1 taken 93 times.
48392 if(combo_has_flags&CHAS_LIFT)
18463 {
18464
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_igetw(&temp_combo.liftcmb,f,true))
18465 return qe_invalid;
18466
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftcs,f,true))
18467 return qe_invalid;
18468
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18469 return qe_invalid;
18470
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftundercs,f,true))
18471 return qe_invalid;
18472
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftdmg,f,true))
18473 return qe_invalid;
18474
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftlvl,f,true))
18475 return qe_invalid;
18476
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftitm,f,true))
18477 return qe_invalid;
18478
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftflags,f,true))
18479 return qe_invalid;
18480
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftgfx,f,true))
18481 return qe_invalid;
18482
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftsprite,f,true))
18483 return qe_invalid;
18484
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftsfx,f,true))
18485 return qe_invalid;
18486
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18487 return qe_invalid;
18488
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18489 return qe_invalid;
18490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(s_version >= 34)
18491 {
18492
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.lifthei,f,true))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(!p_getc(&temp_combo.lifttime,f,true))
18495 return qe_invalid;
18496 93 }
18497
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 42 times.
93 if(s_version >= 39)
18498 {
18499
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&temp_combo.lift_parent_item,f,true))
18500 return qe_invalid;
18501 42 }
18502 93 }
18503
2/2
✓ Branch 0 taken 48378 times.
✓ Branch 1 taken 14 times.
48392 if(combo_has_flags&CHAS_GENERAL)
18504 {
18505
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&temp_combo.speed_mult,f,true))
18506 return qe_invalid;
18507
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&temp_combo.speed_div,f,true))
18508 return qe_invalid;
18509
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetzf(&temp_combo.speed_add,f,true))
18510 return qe_invalid;
18511 14 }
18512 48392 }
18513 136622 return 0;
18514 136622 }
18515 108 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18516 {
18517 108 word section_version=0;
18518 108 word section_cversion=0;
18519 108 word combos_used=0;
18520 int32_t dummy;
18521 byte padding;
18522 108 newcombo temp_combo;
18523
18524 108 reset_combo_animations();
18525 108 reset_combo_animations2();
18526 108 init_combo_classes();
18527
18528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true) //reset combos
18529 {
18530
2/2
✓ Branch 0 taken 7050240 times.
✓ Branch 1 taken 108 times.
7050348 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18531 7050240 combobuf[q].clear();
18532 108 }
18533
18534
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192) //Version info
18535 {
18536
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
18537 {
18538 return qe_invalid;
18539 }
18540 104 FFCore.quest_format[vCombos] = section_version;
18541
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_cversion,f,true))
18542 {
18543 return qe_invalid;
18544 }
18545
18546 //section size
18547
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
18548 {
18549 return qe_invalid;
18550 }
18551 104 }
18552
18553
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(section_version > 32) //Cleanup time!
18554 {
18555
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!p_igetw(&combos_used,f,true))
18556 {
18557 return qe_invalid;
18558 }
18559
2/2
✓ Branch 0 taken 136622 times.
✓ Branch 1 taken 21 times.
136643 for(int32_t i=0; i<combos_used; i++)
18560 {
18561 136622 auto ret = readcombo_loop(f,section_version,temp_combo);
18562
1/2
✓ Branch 0 taken 136622 times.
✗ Branch 1 not taken.
136622 if(ret) return ret;
18563
2/4
✓ Branch 0 taken 136622 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136622 times.
136622 if(keepdata==true && i>=start_combo)
18564 136622 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18565 136622 }
18566 21 }
18567 else //Call the old function for all old versions
18568 {
18569 87 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(ret) return ret; //error, end read
18571 }
18572
18573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
18574 {
18575
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87 times.
108 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18576 {
18577 21 combobuf[0].walk = 0xF0;
18578 21 combobuf[0].type = 0;
18579 21 combobuf[0].flag = 0;
18580 21 }
18581 108 }
18582
18583 108 setup_combo_animations();
18584 108 setup_combo_animations2();
18585 108 return 0;
18586 108 }
18587
18588 99 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18589 {
18590 //these are here to bypass compiler warnings about unused arguments
18591 99 Header=Header;
18592 99 version=version;
18593 99 build=build;
18594
18595 int32_t dummy;
18596 99 word sversion=0, c_sversion;
18597
18598 //section version info
18599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&sversion,f,true))
18600 {
18601 return qe_invalid;
18602 }
18603
18604 99 FFCore.quest_format[vComboAliases] = sversion;
18605
18606 //al_trace("Combo aliases version %d\n", sversion);
18607
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&c_sversion,f,true))
18608 {
18609 return qe_invalid;
18610 }
18611
18612 //section size
18613
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18614 {
18615 return qe_invalid;
18616 }
18617
18618 99 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18619
18620
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 76 times.
99 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18621 {
18622 76 max_num_combo_aliases = MAX250COMBOALIASES;
18623 76 }
18624
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18625 {
18626 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18627 }
18628
18629
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 99 times.
344163 for(int32_t j=0; j<max_num_combo_aliases; j++)
18630 {
18631 byte width,height,mask,tempcset;
18632 int32_t count;
18633 word tempword;
18634 byte tempbyte;
18635
18636
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(!p_igetw(&tempword,f,true))
18637 {
18638 return qe_invalid;
18639 }
18640
18641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344064 times.
344064 if(keepdata)
18642 {
18643 344064 combo_aliases[j].combo = tempword;
18644 344064 }
18645
18646
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(!p_getc(&tempbyte,f,true))
18647 {
18648 return qe_invalid;
18649 }
18650
18651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344064 times.
344064 if(keepdata)
18652 {
18653 344064 combo_aliases[j].cset = tempbyte;
18654 344064 }
18655
18656
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(!p_getc(&width,f,true))
18657 {
18658 return qe_invalid;
18659 }
18660
18661
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(!p_getc(&height,f,true))
18662 {
18663 return qe_invalid;
18664 }
18665
18666
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(!p_getc(&mask,f,true))
18667 {
18668 return qe_invalid;
18669 }
18670
18671 344064 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18672
18673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344064 times.
344064 if(keepdata)
18674 {
18675
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(combo_aliases[j].combos != NULL)
18676 {
18677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344064 times.
344064 delete[] combo_aliases[j].combos;
18678 344064 }
18679
18680
1/2
✓ Branch 0 taken 344064 times.
✗ Branch 1 not taken.
344064 if(combo_aliases[j].csets != NULL)
18681 {
18682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344064 times.
344064 delete[] combo_aliases[j].csets;
18683 344064 }
18684
18685 344064 combo_aliases[j].width = width;
18686 344064 combo_aliases[j].height = height;
18687 344064 combo_aliases[j].layermask = mask;
18688 344064 combo_aliases[j].combos = new word[count];
18689 344064 combo_aliases[j].csets = new byte[count];
18690 344064 }
18691
18692
2/2
✓ Branch 0 taken 352301 times.
✓ Branch 1 taken 344064 times.
696365 for(int32_t k=0; k<count; k++)
18693 {
18694
1/2
✓ Branch 0 taken 352301 times.
✗ Branch 1 not taken.
352301 if(!p_igetw(&tempword,f,true))
18695 {
18696 return qe_invalid;
18697 }
18698
18699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352301 times.
352301 if(keepdata)
18700 {
18701 352301 combo_aliases[j].combos[k] = tempword;
18702 352301 }
18703 352301 }
18704
18705
2/2
✓ Branch 0 taken 352301 times.
✓ Branch 1 taken 344064 times.
696365 for(int32_t k=0; k<count; k++)
18706 {
18707
1/2
✓ Branch 0 taken 352301 times.
✗ Branch 1 not taken.
352301 if(!p_getc(&tempcset,f,true))
18708 {
18709 return qe_invalid;
18710 }
18711
18712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352301 times.
352301 if(keepdata)
18713 {
18714 352301 combo_aliases[j].csets[k] = tempcset;
18715 352301 }
18716 352301 }
18717 344064 }
18718
18719 99 word num_combo_pools = 0;
18720
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 21 times.
99 if(sversion >= 4)
18721 {
18722
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!p_igetw(&num_combo_pools,f,true))
18723 {
18724 return qe_invalid;
18725 }
18726 21 }
18727
18728
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 99 times.
811107 for(combo_pool& pool : combo_pools)
18729 {
18730 811008 pool.clear();
18731 }
18732
18733 99 combo_pool temp_cpool;
18734
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 99 times.
156 for(word cp = 0; cp < num_combo_pools; ++cp)
18735 {
18736 57 int32_t num_combos_in_pool = 0;
18737
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
57 if(!p_igetl(&num_combos_in_pool,f,true))
18738 {
18739 return qe_invalid;
18740 }
18741
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(num_combos_in_pool < 1) continue; //nothing to read
18742
18743
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 temp_cpool.clear();
18744
18745 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18746
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 57 times.
304 for(auto q = 0; q < num_combos_in_pool; ++q)
18747 {
18748
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_igetl(&cp_cid,f,true))
18749 {
18750 return qe_invalid;
18751 }
18752
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_getc(&cp_cs,f,true))
18753 {
18754 return qe_invalid;
18755 }
18756
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_igetw(&cp_quant,f,true))
18757 {
18758 return qe_invalid;
18759 }
18760
1/2
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
247 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18761 247 }
18762
18763
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(keepdata)
18764 {
18765
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 combo_pools[cp] = temp_cpool;
18766 57 }
18767 57 }
18768
18769 99 return 0;
18770 99 }
18771
18772 108 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18773 {
18774 //these are here to bypass compiler warnings about unused arguments
18775
18776 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18777 //Capitalized cause it'll save you a headache. -Deedee
18778 108 start_cset=start_cset;
18779 108 max_csets=max_csets;
18780 108 word s_version=0;
18781
18782 miscQdata temp_misc;
18783 108 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18784
18785 byte temp_colordata[48];
18786 char temp_palname[PALNAMESIZE];
18787
18788 int32_t dummy;
18789 word palcycles;
18790
18791
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
18792 {
18793 //section version info
18794
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
18795 {
18796 return qe_invalid;
18797 }
18798
18799 104 FFCore.quest_format[vCSets] = s_version;
18800
18801 //al_trace("Color data version %d\n", s_version);
18802
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
18803 {
18804 return qe_invalid;
18805 }
18806
18807 //section size
18808
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
18809 {
18810 return qe_invalid;
18811 }
18812 104 }
18813
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
108 if (s_version < 5)
18814 {
18815
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
85 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18816
18817 //finally... section data
18818 85 int32_t q = 0;
18819 85 int32_t p = -15;
18820
2/2
✓ Branch 0 taken 20400 times.
✓ Branch 1 taken 85 times.
20485 for(int32_t i=0; i<oldpdTOTAL; ++i)
18821 {
18822 20400 memset(temp_colordata, 0, 48);
18823
18824
1/2
✓ Branch 0 taken 20400 times.
✗ Branch 1 not taken.
20400 if(!pfread(temp_colordata,48,f,true))
18825 {
18826 return qe_invalid;
18827 }
18828
18829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20400 times.
20400 if(keepdata==true)
18830 {
18831 20400 memcpy(&colordata[q*48], temp_colordata, 48);
18832 20400 }
18833 20400 ++q;
18834
8/8
✓ Branch 0 taken 19040 times.
✓ Branch 1 taken 1360 times.
✓ Branch 2 taken 1445 times.
✓ Branch 3 taken 17595 times.
✓ Branch 4 taken 170 times.
✓ Branch 5 taken 1275 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 162 times.
20400 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18835 {
18836
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if (s_version < 5) //Bumping up the size of level palettes
18837 {
18838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1437 times.
1437 if(keepdata==true)
18839 {
18840 1437 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18841 1437 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18842 1437 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18843 1437 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18844 1437 }
18845 1437 q+=4;
18846 1437 }
18847 else
18848 {
18849 for(int m = 0; m < 4; ++m)
18850 {
18851 memset(temp_colordata, 0, 48);
18852 if(!pfread(temp_colordata,48,f,true))
18853 {
18854 return qe_invalid;
18855 }
18856 if(keepdata==true)
18857 {
18858 memcpy(&colordata[q*48], temp_colordata, 48);
18859 }
18860 ++q;
18861 }
18862 }
18863 1437 }
18864 20400 ++p;
18865 20400 }
18866
18867
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
85 if(RealOldVerion)
18868 {
18869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18870 {
18871 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18872 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18873 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18874 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18875 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18876 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18877 4 }
18878 4 }
18879 else
18880 {
18881 81 memset(temp_colordata, 0, 48);
18882
18883
2/2
✓ Branch 0 taken 253773 times.
✓ Branch 1 taken 81 times.
253854 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18884 {
18885
1/2
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
253773 if(!pfread(temp_colordata,48,f,true))
18886 {
18887 return qe_invalid;
18888 }
18889
18890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253773 times.
253773 if(keepdata==true)
18891 {
18892 253773 memcpy(&colordata[q*48], temp_colordata, 48);
18893 253773 }
18894 253773 ++q;
18895
7/8
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19521 times.
✓ Branch 3 taken 234252 times.
✓ Branch 4 taken 162 times.
✓ Branch 5 taken 19359 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 10 times.
253773 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18896 {
18897
1/2
✓ Branch 0 taken 19511 times.
✗ Branch 1 not taken.
19511 if (s_version < 5) //Bumping up the size of level palettes
18898 {
18899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19511 times.
19511 if(keepdata==true)
18900 {
18901 19511 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18902 19511 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18903 19511 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18904 19511 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18905 19511 }
18906 19511 q+=4;
18907 19511 }
18908 else
18909 {
18910 for(int m = 0; m < 4; ++m)
18911 {
18912 memset(temp_colordata, 0, 48);
18913 if(!pfread(temp_colordata,48,f,true))
18914 {
18915 return qe_invalid;
18916 }
18917 if(keepdata==true)
18918 {
18919 memcpy(&colordata[q*48], temp_colordata, 48);
18920 }
18921 ++q;
18922 }
18923 }
18924 19511 }
18925 253773 ++p;
18926 253773 }
18927
18928
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 76 times.
81 if(s_version < 4)
18929 {
18930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18931 {
18932 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18933 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18934 5 }
18935 5 }
18936 else
18937 {
18938
2/2
✓ Branch 0 taken 252928 times.
✓ Branch 1 taken 76 times.
253004 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18939 {
18940
1/2
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
252928 if(!pfread(temp_colordata,48,f,true))
18941 {
18942 return qe_invalid;
18943 }
18944
18945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252928 times.
252928 if(keepdata==true)
18946 {
18947 252928 memcpy(&colordata[q*48], temp_colordata, 48);
18948 252928 }
18949 252928 ++q;
18950
5/6
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✓ Branch 3 taken 233472 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 19304 times.
252928 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18951 {
18952
1/2
✓ Branch 0 taken 19304 times.
✗ Branch 1 not taken.
19304 if (s_version < 5) //Bumping up the size of level palettes
18953 {
18954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19304 times.
19304 if(keepdata==true)
18955 {
18956 19304 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18957 19304 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18958 19304 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18959 19304 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18960 19304 }
18961 19304 q+=4;
18962 19304 }
18963 else
18964 {
18965 for(int m = 0; m < 4; ++m)
18966 {
18967 memset(temp_colordata, 0, 48);
18968 if(!pfread(temp_colordata,48,f,true))
18969 {
18970 return qe_invalid;
18971 }
18972 if(keepdata==true)
18973 {
18974 memcpy(&colordata[q*48], temp_colordata, 48);
18975 }
18976 ++q;
18977 }
18978 }
18979 19304 }
18980 252928 ++p;
18981 252928 }
18982
18983 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18984 }
18985 }
18986 85 }
18987 else
18988 {
18989
2/2
✓ Branch 0 taken 201227 times.
✓ Branch 1 taken 23 times.
201250 for(int32_t i=0; i<pdTOTAL255; ++i)
18990 {
18991 201227 memset(temp_colordata, 0, 48);
18992
18993
1/2
✓ Branch 0 taken 201227 times.
✗ Branch 1 not taken.
201227 if(!pfread(temp_colordata,48,f,true))
18994 {
18995 return qe_invalid;
18996 }
18997
18998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201227 times.
201227 if(keepdata==true)
18999 {
19000 201227 memcpy(&colordata[i*48], temp_colordata, 48);
19001 201227 }
19002 201227 }
19003 }
19004
19005
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x192)||((version == 0x192)&&(build<76)))
19006 {
19007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19008 {
19009 4 init_palnames();
19010 4 }
19011 4 }
19012 else
19013 {
19014 104 int32_t palnamestoread = 0;
19015
19016
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 3)
19017 5 palnamestoread = OLDMAXLEVELS;
19018 else
19019 99 palnamestoread = 512;
19020
19021
2/2
✓ Branch 0 taken 51968 times.
✓ Branch 1 taken 104 times.
52072 for(int32_t i=0; i<palnamestoread; ++i)
19022 {
19023 51968 memset(temp_palname, 0, PALNAMESIZE);
19024
19025
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19026 {
19027 return qe_invalid;
19028 }
19029
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51968 times.
51968 if(keepdata==true)
19031 {
19032 51968 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19033 51968 }
19034 51968 }
19035
19036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
19037 {
19038
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 104 times.
1384 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19039 {
19040 1280 memset(palnames[i], 0, PALNAMESIZE);
19041 1280 }
19042 104 }
19043 }
19044
19045
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
19046 {
19047
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<256; i++)
19048 {
19049
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 26624 times.
106496 for(int32_t j=0; j<3; j++)
19050 {
19051 79872 temp_misc.cycles[i][j].first=0;
19052 79872 temp_misc.cycles[i][j].count=0;
19053 79872 temp_misc.cycles[i][j].speed=0;
19054 79872 }
19055 26624 }
19056
19057
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&palcycles,f,true))
19058 {
19059 return qe_invalid;
19060 }
19061
19062
2/2
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 104 times.
3536 for(int32_t i=0; i<palcycles; i++)
19063 {
19064
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 3432 times.
13728 for(int32_t j=0; j<3; j++)
19065 {
19066
1/2
✓ Branch 0 taken 10296 times.
✗ Branch 1 not taken.
10296 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19067 {
19068 return qe_invalid;
19069 }
19070 10296 }
19071
19072
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 3432 times.
13728 for(int32_t j=0; j<3; j++)
19073 {
19074
1/2
✓ Branch 0 taken 10296 times.
✗ Branch 1 not taken.
10296 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19075 {
19076 return qe_invalid;
19077 }
19078 10296 }
19079
19080
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 3432 times.
13728 for(int32_t j=0; j<3; j++)
19081 {
19082
1/2
✓ Branch 0 taken 10296 times.
✗ Branch 1 not taken.
10296 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19083 {
19084 return qe_invalid;
19085 }
19086 10296 }
19087 3432 }
19088
19089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
19090 {
19091 104 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19092 104 }
19093 104 }
19094
19095 108 return 0;
19096 108 }
19097
19098 108 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19099 {
19100 108 int32_t tiles_used=0;
19101 108 word section_version = 0;
19102 108 word section_cversion = 0;
19103 108 int32_t section_size= 0;
19104 108 byte *temp_tile = new byte[tilesize(tf32Bit)];
19105
19106 //Tile Expansion
19107 //if ( version >= 0x254 && build >= 41 )
19108
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
108 if (version < 0x254 && build < 41)
19109 {
19110 //al_trace("Build was < 41 when reading tiles\n");
19111 85 max_tiles = ZC250MAXTILES;
19112 85 }
19113
19114 //al_trace("Max Tiles: %d\n", max_tiles);
19115
19116
2/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19117 {
19118 if(keepdata==true)
19119 {
19120 if(!init_tiles(true, Header))
19121 {
19122 al_trace("Unable to initialize tiles\n");
19123 }
19124 }
19125
19126 delete[] temp_tile;
19127 temp_tile=NULL;
19128 return 0;
19129 }
19130 else
19131 {
19132
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
19133 {
19134 //section version info
19135
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
19136 {
19137 delete[] temp_tile;
19138 return qe_invalid;
19139 }
19140
19141 104 FFCore.quest_format[vTiles] = section_version;
19142
19143
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_cversion,f,true))
19144 {
19145 delete[] temp_tile;
19146 return qe_invalid;
19147 }
19148
19149 //section size
19150
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&section_size,f,true))
19151 {
19152 delete[] temp_tile;
19153 return qe_invalid;
19154 }
19155 104 }
19156
19157 //if ( build < 41 )
19158 //{
19159 // tiles_used = ZC250MAXTILES;
19160 //}
19161
19162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(version < 0x174)
19163 {
19164 tiles_used=TILES_PER_PAGE*4;
19165 } //no expanded tile space
19166
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 else if(version < 0x191)
19167 {
19168 4 tiles_used=OLDMAXTILES;
19169 4 }
19170 else
19171 {
19172 //finally... section data
19173
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
104 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19174 {
19175
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tiles_used,f,true))
19176 {
19177 delete[] temp_tile;
19178 return qe_invalid;
19179 }
19180 23 }
19181 else
19182 {
19183
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetw(&tiles_used,f,true))
19184 {
19185 delete[] temp_tile;
19186 return qe_invalid;
19187 }
19188 }
19189 }
19190
19191
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 tiles_used=zc_min(tiles_used, max_tiles);
19192
19193 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19194 //if ( version < 0x254 && build < 41 )
19195
3/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if ( version < 0x254 || (version == 0x254 && build < 41) )
19196 //if ( build < 41 )
19197 {
19198
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19199 85 }
19200 else //2.55
19201 {
19202
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19203 }
19204
19205 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19206
19207 //al_trace("tiles_used = %d\n", tiles_used);
19208
19209
2/2
✓ Branch 0 taken 2480425 times.
✓ Branch 1 taken 108 times.
2480533 for(int32_t i=0; i<tiles_used; ++i)
19210 {
19211 2480425 byte format=tf4Bit;
19212 2480425 memset(temp_tile, 0, tilesize(tf32Bit));
19213
19214
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2308187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2480425 if((version>0x211)||((version==0x211)&&(build>4)))
19215 {
19216
1/2
✓ Branch 0 taken 2308187 times.
✗ Branch 1 not taken.
2308187 if(!p_getc(&format,f,true))
19217 {
19218 delete[] temp_tile;
19219 return qe_invalid;
19220 }
19221 2308187 }
19222
4/4
✓ Branch 0 taken 768422 times.
✓ Branch 1 taken 1712003 times.
✓ Branch 2 taken 381251 times.
✓ Branch 3 taken 387171 times.
2480425 if(section_version > 2 && !format)
19223 {
19224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387171 times.
387171 if(keepdata)
19225 {
19226 387171 reset_tile(buf,start_tile+i,tf4Bit);
19227 387171 }
19228 387171 continue;
19229 }
19230
19231
1/2
✓ Branch 0 taken 2093254 times.
✗ Branch 1 not taken.
2093254 if(!pfread(temp_tile,tilesize(format),f,true))
19232 {
19233 delete[] temp_tile;
19234 return qe_invalid;
19235 }
19236
19237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2093254 times.
2093254 if(keepdata==true)
19238 {
19239 2093254 buf[start_tile+i].format=format;
19240
19241
1/2
✓ Branch 0 taken 2093254 times.
✗ Branch 1 not taken.
2093254 if(buf[start_tile+i].data)
19242 {
19243 2093254 free(buf[start_tile+i].data);
19244 2093254 buf[start_tile+i].data=NULL;
19245 2093254 }
19246
19247 2093254 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19248 2093254 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19249 2093254 }
19250 2093254 }
19251 }
19252
19253
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19254 {
19255 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19256
2/2
✓ Branch 0 taken 12663300 times.
✓ Branch 1 taken 85 times.
12663385 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19257 {
19258
19259 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19260 12663300 reset_tile(buf,q,tf4Bit);
19261
19262
19263 /*
19264
19265 byte tempbyte;
19266 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19267 {
19268 tempbyte=buf[ZC250MAXTILES-1].data[i];
19269 buf[q].data[i] = tempbyte;
19270 }
19271 //int32_t temp = tempbyte=buf[130].data[i];
19272 //buf[q].data = buf[ZC250MAXTILES-1].data;
19273 */
19274 //reset_tile(buf,q,tf4Bit);
19275 12663300 }
19276
19277 85 }
19278
19279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19280 {
19281
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
108 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19282 {
19283
2/2
✓ Branch 0 taken 4065817 times.
✓ Branch 1 taken 85 times.
4065902 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19284 {
19285 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19286 4065817 reset_tile(buf,i,tf4Bit);
19287 4065817 }
19288 85 }
19289 else
19290 {
19291
2/2
✓ Branch 0 taken 3956458 times.
✓ Branch 1 taken 23 times.
3956481 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19292 {
19293 //al_trace("Resetting tiles for build 41+\n");
19294 3956458 reset_tile(buf,i,tf4Bit);
19295 3956458 }
19296 }
19297
19298
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19299 {
19300
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19301 {
19302 byte tempbyte;
19303 int32_t floattile=wpnsbuf[iwSwim].tile;
19304
19305 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19306 {
19307 tempbyte=buf[23].data[i];
19308 buf[23].data[i]=buf[24].data[i];
19309 buf[24].data[i]=buf[25].data[i];
19310 buf[25].data[i]=buf[26].data[i];
19311 buf[26].data[i]=tempbyte;
19312 }
19313 //swim tiles are out of order, too, but nobody cared? -Z
19314 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19315 {
19316 tempbyte=buf[floattile+11].data[i];
19317 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19318 buf[floattile+12].data[i]=tempbyte;
19319 }
19320 }
19321 4 }
19322
19323
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19324 {
19325
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19326 {
19327 byte tempbyte;
19328
19329
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19330 {
19331 512 tempbyte=buf[130].data[i];
19332 512 buf[130].data[i]=buf[132].data[i];
19333 512 buf[132].data[i]=tempbyte;
19334
19335 512 tempbyte=buf[131].data[i];
19336 512 buf[131].data[i]=buf[133].data[i];
19337 512 buf[133].data[i]=tempbyte;
19338 512 }
19339 4 }
19340 9 }
19341
19342 108 al_trace("Registering blank tiles\n");
19343 108 register_blank_tiles();
19344 108 }
19345
19346 //memset(temp_tile, 0, tilesize(tf32Bit));
19347
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 delete[] temp_tile;
19348 108 temp_tile=NULL;
19349 108 return 0;
19350 108 }
19351
19352 108 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19353 {
19354 108 byte *mf=midi_flags;
19355 int32_t dummy;
19356 word dummy2;
19357 // zcmidi_ temp_midi;
19358 int32_t tunes_to_read;
19359 108 int32_t tune_count=0;
19360 108 word section_version=0;
19361 108 zctune temp;
19362
19363
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version < 0x193)
19364 {
19365 // mf=Header->data_flags+ZQ_MIDIS2;
19366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19367 {
19368 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19369 4 }
19370 else
19371 {
19372 tunes_to_read=MAXCUSTOMTUNES;
19373 }
19374 4 }
19375 else
19376 {
19377 //section version info
19378
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
19379 {
19380 return qe_invalid;
19381 }
19382
19383 104 FFCore.quest_format[vMIDIs] = section_version;
19384
19385 //al_trace("Tunes version %d\n", section_version);
19386
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy2,f,true))
19387 {
19388 return qe_invalid;
19389 }
19390
19391 //section size
19392
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
19393 {
19394 return qe_invalid;
19395 }
19396
19397 //finally... section data
19398
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19399 {
19400 return qe_invalid;
19401 }
19402
19403 104 tunes_to_read=MAXCUSTOMTUNES;
19404 }
19405
19406
2/2
✓ Branch 0 taken 27216 times.
✓ Branch 1 taken 108 times.
27324 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19407 {
19408
2/2
✓ Branch 0 taken 25350 times.
✓ Branch 1 taken 1866 times.
27216 if(get_bit(mf, i))
19409 {
19410 1866 ++tune_count;
19411 1866 }
19412 27216 }
19413
19414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19415 {
19416 108 reset_tunes(tunes); //reset_midis(midis);
19417 108 }
19418
19419
2/2
✓ Branch 0 taken 26336 times.
✓ Branch 1 taken 108 times.
26444 for(int32_t i=0; i<tunes_to_read; i++)
19420 {
19421 26336 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19422
19423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26336 times.
26336 if(keepdata==true)
19424 {
19425 26336 tunes[i].reset(); // reset_midi(midis+i);
19426 26336 }
19427
19428
2/2
✓ Branch 0 taken 24470 times.
✓ Branch 1 taken 1866 times.
26336 if(get_bit(mf,i))
19429 {
19430
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1569 times.
1866 if(section_version < 4)
19431 {
19432
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19433 {
19434 return qe_invalid;
19435 }
19436 297 }
19437 else
19438 {
19439
1/2
✓ Branch 0 taken 1569 times.
✗ Branch 1 not taken.
1569 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19440 {
19441 return qe_invalid;
19442 }
19443 }
19444
19445
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!p_igetl(&temp.start,f,true))
19446 {
19447 return qe_invalid;
19448 }
19449
19450
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!p_igetl(&temp.loop_start,f,true))
19451 {
19452 return qe_invalid;
19453 }
19454
19455
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!p_igetl(&temp.loop_end,f,true))
19456 {
19457 return qe_invalid;
19458 }
19459
19460
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!p_igetw(&temp.loop,f,true))
19461 {
19462 return qe_invalid;
19463 }
19464
19465
1/2
✓ Branch 0 taken 1866 times.
✗ Branch 1 not taken.
1866 if(!p_igetw(&temp.volume,f,true))
19466 {
19467 return qe_invalid;
19468 }
19469
19470
2/2
✓ Branch 0 taken 1788 times.
✓ Branch 1 taken 78 times.
1866 if(Header->zelda_version < 0x193)
19471 {
19472
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19473 {
19474 return qe_invalid;
19475 }
19476 78 }
19477
19478
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1569 times.
1866 if(section_version >= 3)
19479 {
19480
1/2
✓ Branch 0 taken 1569 times.
✗ Branch 1 not taken.
1569 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19481 {
19482 return qe_invalid;
19483 }
19484 1569 }
19485
19486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1866 times.
1866 if(keepdata==true)
19487 {
19488 1866 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19489 1866 }
19490
19491
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1569 times.
1866 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19492 {
19493 // old format - a midi is a midi
19494
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19495 {
19496 return qe_invalid;
19497 }
19498
19499 //yes you can do this. Isn't the ? operator awesome? :)
19500
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19501 297 }
19502 else
19503 {
19504 // 'midi' could be midi or nes, gb, ... music
19505
2/4
✓ Branch 0 taken 1569 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1569 times.
✗ Branch 3 not taken.
1569 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19506 {
19507 return qe_invalid;
19508 }
19509
19510
1/2
✓ Branch 0 taken 1569 times.
✗ Branch 1 not taken.
1569 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19511
19512
1/2
✓ Branch 0 taken 1569 times.
✗ Branch 1 not taken.
1569 switch(temp.format)
19513 {
19514 case MFORMAT_MIDI:
19515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1569 times.
1569 if((ptr->data=read_midi(f, true))==NULL)
19516 {
19517 return qe_invalid;
19518 }
19519
19520 1569 break;
19521
19522 default:
19523 return qe_invalid;
19524 break;
19525 }
19526 }
19527 1866 }
19528 26336 }
19529
19530 108 return 0;
19531 108 }
19532
19533 108 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19534 {
19535 int32_t dummy;
19536 ZCHEATS tempzcheats;
19537 108 char temp_use_cheats=1;
19538 108 memset(&tempzcheats, 0, sizeof(tempzcheats));
19539 108 word s_version = 0;
19540
19541
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
19542 {
19543 //section version info
19544
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
19545 {
19546 return qe_invalid;
19547 }
19548
19549 104 FFCore.quest_format[vCheats] = s_version;
19550 //al_trace("Cheats version %d\n", dummy);
19551
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
19552 {
19553 return qe_invalid;
19554 }
19555
19556 //section size
19557
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
19558 {
19559 return qe_invalid;
19560 }
19561
19562 //finally... section data
19563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&temp_use_cheats,f,true))
19564 {
19565 return qe_invalid;
19566 }
19567 104 }
19568
19569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(Header->data_flags[ZQ_CHEATS2])
19570 {
19571
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tempzcheats.flags,f,true))
19572 {
19573 return qe_invalid;
19574 }
19575
19576
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19577 {
19578 return qe_invalid;
19579 }
19580 108 }
19581
19582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19583 {
19584 108 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19585 108 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19586 108 }
19587
19588 108 return 0;
19589 108 }
19590
19591 270 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19592 {
19593 int32_t dummy;
19594 270 word s_version=0, s_cversion=0;
19595 byte padding;
19596 word tempw;
19597
19598 270 zinitdata temp_zinit;
19599
19600 // Legacy item properties (now integrated into itemdata)
19601 byte sword_hearts[4];
19602 byte beam_hearts[4];
19603 270 byte beam_percent=0;
19604 word beam_power[4];
19605 270 byte hookshot_length=99;
19606 270 byte hookshot_links=100;
19607 270 byte longshot_length=99;
19608 270 byte longshot_links=100;
19609 270 byte moving_fairy_hearts=3;
19610 270 byte moving_fairy_heart_percent=0;
19611 270 byte stationary_fairy_hearts=3;
19612 270 byte stationary_fairy_heart_percent=0;
19613 270 byte moving_fairy_magic=0;
19614 270 byte moving_fairy_magic_percent=0;
19615 270 byte stationary_fairy_magic=0;
19616 270 byte stationary_fairy_magic_percent=0;
19617 270 byte blue_potion_hearts=100;
19618 270 byte blue_potion_heart_percent=1;
19619 270 byte red_potion_hearts=100;
19620 270 byte red_potion_heart_percent=1;
19621 270 byte blue_potion_magic=100;
19622 270 byte blue_potion_magic_percent=1;
19623 270 byte red_potion_magic=100;
19624 270 byte red_potion_magic_percent=1;
19625
19626
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 162 times.
270 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19627
19628
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version > 0x192)
19629 {
19630 //section version info
19631
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_version,f,true))
19632 {
19633 return qe_invalid;
19634 }
19635
19636 104 FFCore.quest_format[vInitData] = s_version;
19637
19638 //al_trace("Init data version %d\n", s_version);
19639
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_cversion,f,true))
19640 {
19641 return qe_invalid;
19642 }
19643
19644 //section size
19645
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetl(&dummy,f,true))
19646 {
19647 return qe_invalid;
19648 }
19649 104 }
19650
19651 /* HIGHLY UNORTHODOX UPDATING THING, by L
19652 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19653 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19654 * changing from 13 to 14.
19655 */
19656
3/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 9 times.
108 if(keepdata && s_version < 14)
19657 9 fixpolsvoice=true;
19658
19659 /* End highly unorthodox updating thing */
19660
19661
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 25 times.
108 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19662 25 temp_zinit.jump_hero_layer_threshold=0;
19663
19664
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version >= 10)
19665 {
19666 char temp;
19667
19668 //new-style items
19669
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t j=0; j<256; j++)
19670 {
19671
2/4
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(!p_getc(&temp,f,true))
19672 return qe_invalid;
19673
19674 25344 temp_zinit.items[j] = (temp != 0);
19675 25344 }
19676 99 }
19677
19678
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 58 times.
108 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19679 {
19680 char temp;
19681
19682 //finally... section data
19683
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 58 times.
162 if((Header->zelda_version > 0x192)||
19684 //new only
19685 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19686 {
19687 //OLD-style items... sigh
19688
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 10)
19689 {
19690
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19691 {
19692 return qe_invalid;
19693 }
19694
19695 5 temp_zinit.items[iRaft]=(temp != 0);
19696
19697
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19698 {
19699 return qe_invalid;
19700 }
19701
19702 5 temp_zinit.items[iLadder]=(temp != 0);
19703
19704
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19705 {
19706 return qe_invalid;
19707 }
19708
19709 5 temp_zinit.items[iBook]=(temp != 0);
19710
19711
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19712 {
19713 return qe_invalid;
19714 }
19715
19716 5 temp_zinit.items[iMKey]=(temp!=0);
19717
19718
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19719 {
19720 return qe_invalid;
19721 }
19722
19723 5 temp_zinit.items[iFlippers]=(temp != 0);
19724
19725
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19726 {
19727 return qe_invalid;
19728 }
19729
19730 5 temp_zinit.items[iBoots]=(temp!=0);
19731 5 }
19732 104 }
19733
19734
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 157 times.
162 if(s_version < 10)
19735 {
19736 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19737
19738
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19739 {
19740 return qe_invalid;
19741 }
19742
19743
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19744 {
19745 return qe_invalid;
19746 }
19747
19748
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19749 {
19750 return qe_invalid;
19751 }
19752
19753
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19754 {
19755 return qe_invalid;
19756 }
19757
19758
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19759 {
19760 return qe_invalid;
19761 }
19762
19763
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19764 {
19765 return qe_invalid;
19766 }
19767
19768
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19769 {
19770 return qe_invalid;
19771 }
19772
19773 //old only
19774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19775 {
19776 tempring=(tempring)?(1<<(tempring-1)):0;
19777 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19778 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19779 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19780 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19781 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19782 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19783 }
19784
19785 //rings start at level 2... wtf
19786 //account for this -DD
19787 5 tempring <<= 1;
19788
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19789
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19790
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19791
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19792 //bracelet ALSO starts at level 2 :-( -DD
19793 5 tempbracelet<<=1;
19794
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19795
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19796
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19797
19798 //new only
19799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19800 {
19801 for(int32_t q=0; q<32; q++)
19802 {
19803 if(!p_getc(&padding,f,true))
19804 {
19805 return qe_invalid;
19806 }
19807 }
19808 }
19809
19810 char tempcandle, tempboomerang, temparrow, tempwhistle;
19811
19812
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19813 {
19814 return qe_invalid;
19815 }
19816
19817
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19818 {
19819 return qe_invalid;
19820 }
19821
19822
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19823 {
19824 return qe_invalid;
19825 }
19826
19827
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19828 {
19829 return qe_invalid;
19830 }
19831
19832
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19833
19834
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19835 {
19836 return qe_invalid;
19837 }
19838
19839 //old only
19840
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19841 {
19842 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19843 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19844 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19845 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19846 }
19847
19848
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19849
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19850
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19851
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19852 //What about the potion...?
19853
19854 5 }
19855
19856
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 81 times.
162 if(s_version < 29)
19857 {
19858 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19859 //to jab out my eye...
19860
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19861 return qe_invalid;
19862 81 temp_zinit.bombs = padding;
19863
19864
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19865 return qe_invalid;
19866 81 temp_zinit.super_bombs = padding;
19867 81 }
19868
19869 //Back to more OLD item code
19870
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
162 if(s_version < 10)
19871 {
19872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19873 //new only
19874 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19875 {
19876
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19877 {
19878 return qe_invalid;
19879 }
19880
19881
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19882
19883
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19884 {
19885 return qe_invalid;
19886 }
19887
19888
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19889
19890
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19891 {
19892 return qe_invalid;
19893 }
19894
19895
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19896
19897
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19898 {
19899 return qe_invalid;
19900 }
19901
19902
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19903
19904
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19905 {
19906 return qe_invalid;
19907 }
19908
19909
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19910
19911
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19912 {
19913 return qe_invalid;
19914 }
19915
19916
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19917
19918
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19919 {
19920 return qe_invalid;
19921 }
19922
19923
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19924
19925
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19926 {
19927 return qe_invalid;
19928 }
19929
19930
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19931
19932
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19933 {
19934 return qe_invalid;
19935 }
19936
19937
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19938
19939
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19940 {
19941 return qe_invalid;
19942 }
19943
19944
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19945 {
19946 for(int32_t q=0; q<32; q++)
19947 {
19948 if(!p_getc(&padding,f,true))
19949 {
19950 return qe_invalid;
19951 }
19952 }
19953 }
19954 5 }
19955 5 }
19956
19957 //old only
19958
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19959 {
19960 byte equipment, items; //bit flags
19961
19962 if(!p_getc(&equipment,f,true))
19963 {
19964 return qe_invalid;
19965 }
19966
19967 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19968 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19969 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19970 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19971 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19972 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19973
19974
19975 if(!p_getc(&items,f,true))
19976 {
19977 return qe_invalid;
19978 }
19979
19980 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19981 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19982 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19983 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19984 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19985 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19986 }
19987
19988 if(!p_getc(&temp_zinit.hc,f,true))
19989 {
19990 return qe_invalid;
19991 }
19992
19993
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 14)
19994 {
19995 byte temphp;
19996
19997
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
19998 {
19999 return qe_invalid;
20000 }
20001
20002 5 temp_zinit.start_heart=temphp;
20003
20004
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20005 {
20006 return qe_invalid;
20007 }
20008
20009 5 temp_zinit.cont_heart=temphp;
20010 5 }
20011 else
20012 {
20013
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.start_heart,f,true))
20014 {
20015 return qe_invalid;
20016 }
20017
20018
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20019 {
20020 return qe_invalid;
20021 }
20022 }
20023
20024
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.hcp,f,true))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version >= 14)
20030 {
20031
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20032 {
20033 return qe_invalid;
20034 }
20035
20036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version<16) // July 2007
20037 {
20038 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20039 temp_zinit.hcp_per_hc = 0xFF;
20040
20041 //Dispose of legacy rule
20042 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20043 }
20044 99 }
20045
20046
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(s_version < 29)
20047 {
20048
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20049 return qe_invalid;
20050 81 temp_zinit.max_bombs = padding;
20051 81 }
20052
20053
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.keys,f,true))
20054 {
20055 return qe_invalid;
20056 }
20057
20058
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&temp_zinit.rupies,f,true))
20059 {
20060 return qe_invalid;
20061 }
20062
20063
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.triforce,f,true))
20064 {
20065 return qe_invalid;
20066 }
20067
20068
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20069 {
20070
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20071 {
20072
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.map[i],f,true))
20073 {
20074 return qe_invalid;
20075 }
20076 6336 }
20077
20078
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20079 {
20080
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.compass[i],f,true))
20081 {
20082 return qe_invalid;
20083 }
20084 6336 }
20085 99 }
20086 else
20087 {
20088
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20089 {
20090
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20091 {
20092 return qe_invalid;
20093 }
20094 160 }
20095
20096
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20097 {
20098
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20099 {
20100 return qe_invalid;
20101 }
20102 160 }
20103 }
20104
20105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version > 0x192)||
20106 //new only
20107 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20108 {
20109
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20110 {
20111
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20112 {
20113
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20114 {
20115 return qe_invalid;
20116 }
20117 6336 }
20118 99 }
20119 else
20120 {
20121
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20122 {
20123
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20124 {
20125 return qe_invalid;
20126 }
20127 160 }
20128 }
20129 104 }
20130
20131
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1664 times.
1768 for(int32_t i=0; i<16; i++)
20132 {
20133
2/4
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1664 times.
1664 if(!p_getc(&temp_zinit.misc[i],f,true))
20134 {
20135 return qe_invalid;
20136 }
20137 1664 }
20138
20139
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
124 if(s_version < 15) for(int32_t i=0; i<4; i++)
20140 {
20141
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20142 {
20143 return qe_invalid;
20144 }
20145 25 }
20146
20147
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.last_map,f,true))
20148 {
20149 return qe_invalid;
20150 }
20151
20152
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.last_screen,f,true))
20153 {
20154 return qe_invalid;
20155 }
20156
20157
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 14)
20158 {
20159 byte tempmp;
20160
20161
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20162 {
20163 return qe_invalid;
20164 }
20165
20166 5 temp_zinit.max_magic=tempmp;
20167
20168
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20169 {
20170 return qe_invalid;
20171 }
20172
20173 5 temp_zinit.magic=tempmp;
20174 5 }
20175 else
20176 {
20177
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_magic,f,true))
20178 {
20179 return qe_invalid;
20180 }
20181
20182
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.magic,f,true))
20183 {
20184 return qe_invalid;
20185 }
20186 }
20187
20188
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version < 15)
20189 {
20190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20191 {
20192 5 temp_zinit.max_magic*=32;
20193 5 temp_zinit.magic*=32;
20194 5 }
20195
20196
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20197 {
20198
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20199 {
20200 return qe_invalid;
20201 }
20202 20 }
20203
20204
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20205 {
20206 return qe_invalid;
20207 }
20208 5 }
20209 else
20210 {
20211
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20212 {
20213 return qe_invalid;
20214 }
20215 }
20216
20217
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version < 15)
20218 {
20219 byte tempbp;
20220
20221
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20222 {
20223
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 20 beam_power[i]=tempbp;
20229 20 }
20230
20231
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20232 {
20233 return qe_invalid;
20234 }
20235
20236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20237 {
20238 if(!p_getc(&hookshot_length,f,true))
20239 {
20240 return qe_invalid;
20241 }
20242
20243 if(!p_getc(&longshot_links,f,true))
20244 {
20245 return qe_invalid;
20246 }
20247
20248 if(!p_getc(&longshot_length,f,true))
20249 {
20250 return qe_invalid;
20251 }
20252 }
20253 5 }
20254
20255
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20256 {
20257 return qe_invalid;
20258 }
20259
20260
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20261 {
20262 return qe_invalid;
20263 }
20264
20265
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.subscreen,f,true))
20266 {
20267 return qe_invalid;
20268 }
20269
20270 //old only
20271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version == 0x192)&&(Header->build<174))
20272 {
20273 for(int32_t i=0; i<32; i++)
20274 {
20275 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20276 {
20277 return qe_invalid;
20278 }
20279 }
20280 }
20281
20282
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20283 {
20284
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version <= 10)
20285 {
20286 byte tempbyte;
20287
20288
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20289 {
20290 return qe_invalid;
20291 }
20292
20293 5 temp_zinit.start_dmap = (word)tempbyte;
20294 5 }
20295 else
20296 {
20297
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20298 {
20299 return qe_invalid;
20300 }
20301 }
20302
20303
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20304 {
20305 return qe_invalid;
20306 }
20307 104 }
20308
20309
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 23 times.
104 if(s_version>1 && s_version < 29)
20310 {
20311
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20312 return qe_invalid;
20313 76 temp_zinit.arrows = padding;
20314
20315
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20316 return qe_invalid;
20317 76 temp_zinit.max_arrows = padding;
20318 76 }
20319
20320
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version>2)
20321 {
20322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version <= 10)
20323 {
20324 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20325 {
20326 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20327 {
20328 return qe_invalid;
20329 }
20330 }
20331 }
20332 else
20333 {
20334
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXLEVELS; i++)
20335 {
20336
2/4
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50688 times.
✗ Branch 3 not taken.
50688 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20337 {
20338 return qe_invalid;
20339 }
20340 50688 }
20341 }
20342 99 }
20343
20344
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>3)
20345 {
20346
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20347 {
20348 return qe_invalid;
20349 }
20350
20351
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20352 {
20353 return qe_invalid;
20354 }
20355
20356
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20357 {
20358 return qe_invalid;
20359 }
20360
20361
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20362 {
20363 return qe_invalid;
20364 }
20365
20366
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20367 {
20368 return qe_invalid;
20369 }
20370
20371
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20372 {
20373 return qe_invalid;
20374 }
20375
20376
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20377 {
20378 return qe_invalid;
20379 }
20380
20381
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20382 {
20383 return qe_invalid;
20384 }
20385
20386
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20387
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20388 99 }
20389
20390
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>4 && s_version<15)
20391 {
20392 if(!p_getc(&moving_fairy_hearts,f,true))
20393 {
20394 return qe_invalid;
20395 }
20396
20397 if(!p_getc(&moving_fairy_heart_percent,f,true))
20398 {
20399 return qe_invalid;
20400 }
20401 }
20402
20403
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>5 && s_version < 10)
20404 {
20405 if(!p_getc(&temp,f,true))
20406 {
20407 return qe_invalid;
20408 }
20409
20410 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20411 }
20412
20413
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>6 && s_version<15)
20414 {
20415 if(!p_getc(&stationary_fairy_hearts,f,true))
20416 {
20417 return qe_invalid;
20418 }
20419
20420 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20421 {
20422 return qe_invalid;
20423 }
20424
20425 if(!p_getc(&moving_fairy_magic,f,true))
20426 {
20427 return qe_invalid;
20428 }
20429
20430 if(!p_getc(&moving_fairy_magic_percent,f,true))
20431 {
20432 return qe_invalid;
20433 }
20434
20435 if(!p_getc(&stationary_fairy_magic,f,true))
20436 {
20437 return qe_invalid;
20438 }
20439
20440 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20441 {
20442 return qe_invalid;
20443 }
20444
20445 if(!p_getc(&blue_potion_hearts,f,true))
20446 {
20447 return qe_invalid;
20448 }
20449
20450 if(!p_getc(&blue_potion_heart_percent,f,true))
20451 {
20452 return qe_invalid;
20453 }
20454
20455 if(!p_getc(&red_potion_hearts,f,true))
20456 {
20457 return qe_invalid;
20458 }
20459
20460 if(!p_getc(&red_potion_heart_percent,f,true))
20461 {
20462 return qe_invalid;
20463 }
20464
20465 if(!p_getc(&blue_potion_magic,f,true))
20466 {
20467 return qe_invalid;
20468 }
20469
20470 if(!p_getc(&blue_potion_magic_percent,f,true))
20471 {
20472 return qe_invalid;
20473 }
20474
20475 if(!p_getc(&red_potion_magic,f,true))
20476 {
20477 return qe_invalid;
20478 }
20479
20480 if(!p_getc(&red_potion_magic_percent,f,true))
20481 {
20482 return qe_invalid;
20483 }
20484 }
20485
20486
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>6)
20487 {
20488
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20489 {
20490 return qe_invalid;
20491 }
20492 99 }
20493
20494
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>7)
20495 {
20496
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20497 {
20498 return qe_invalid;
20499 }
20500 99 }
20501
20502
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>8)
20503 {
20504
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20505 {
20506 return qe_invalid;
20507 }
20508
20509
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_keys,f,true))
20510 {
20511 return qe_invalid;
20512 }
20513 99 }
20514
20515
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>16)
20516 {
20517
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.gravity,f,true))
20518 {
20519 return qe_invalid;
20520 }
20521
20522
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.terminalv,f,true))
20523 {
20524 return qe_invalid;
20525 }
20526
20527
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_speed,f,true))
20528 {
20529 return qe_invalid;
20530 }
20531
20532
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.transition_type,f,true))
20533 {
20534 return qe_invalid;
20535 }
20536
20537
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20538 {
20539 return qe_invalid;
20540 }
20541 99 }
20542
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20543 5 temp_zinit.msg_speed = 0;
20544
20545
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>17)
20546 {
20547
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20548 {
20549 return qe_invalid;
20550 }
20551 99 }
20552
20553 //expaned init data for larger values in 2.55
20554
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20555 {
20556
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.bombs,f,true))
20557 {
20558 return qe_invalid;
20559 }
20560
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20561 {
20562 return qe_invalid;
20563 }
20564
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20565 {
20566 return qe_invalid;
20567 }
20568
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20569 {
20570 return qe_invalid;
20571 }
20572
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.arrows,f,true))
20573 {
20574 return qe_invalid;
20575 }
20576
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20577 {
20578 return qe_invalid;
20579 }
20580
20581 23 }
20582
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( s_version >= 20 )
20583 {
20584
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroStep,f,true))
20585 {
20586 return qe_invalid;
20587 }
20588 23 }
20589 else
20590 {
20591 81 temp_zinit.heroStep = 150; //1.5 pixels per frame
20592 }
20593
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( s_version >= 21 )
20594 {
20595
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20596 {
20597 return qe_invalid;
20598 }
20599 23 }
20600 else
20601 {
20602 81 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20603 }
20604 //old only
20605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version == 0x192)&&(Header->build<174))
20606 {
20607 byte items2;
20608
20609 if(!p_getc(&items2,f,true))
20610 {
20611 return qe_invalid;
20612 }
20613
20614 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20615 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20616 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20617 }
20618
20619
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
20620 {
20621 for(int32_t q=0; q<96; q++)
20622 {
20623 if(!p_getc(&padding,f,true))
20624 {
20625 return qe_invalid;
20626 }
20627 }
20628
20629 //new only
20630 if((Header->zelda_version == 0x192)&&(Header->build>173))
20631 {
20632 if(!p_getc(&padding,f,true))
20633 {
20634 return qe_invalid;
20635 }
20636
20637 if(!p_getc(&padding,f,true))
20638 {
20639 return qe_invalid;
20640 }
20641 }
20642 }
20643 104 }
20644
20645
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20646 {
20647 //temp_zinit.shield=i_smallshield;
20648
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 58 times.
67 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20649
20650
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20651 9 temp_zinit.items[sshieldid] = true;
20652 9 }
20653
20654
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20655 {
20656 4 temp_zinit.hc=3;
20657 4 temp_zinit.start_heart=3;
20658 4 temp_zinit.cont_heart=3;
20659 4 temp_zinit.max_bombs=8;
20660 4 }
20661
20662
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20663 {
20664 4 sword_hearts[0]=0;
20665 4 sword_hearts[1]=5;
20666 4 sword_hearts[2]=12;
20667 4 sword_hearts[3]=21;
20668 4 }
20669
20670
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20671 {
20672 4 temp_zinit.last_map=0;
20673 4 temp_zinit.last_screen=0;
20674 4 }
20675
20676
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20677 {
20678 4 temp_zinit.max_magic=0;
20679 4 temp_zinit.magic=0;
20680
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20681 4 }
20682
20683
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20684 {
20685
20686
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20687 {
20688 16 beam_hearts[x]=100;
20689 16 }
20690
20691
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20692 {
20693
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20694
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20695 16 }
20696
20697
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20698 {
20699
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20700 16 }
20701
20702
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20703 4 hookshot_links=100;
20704 4 temp_zinit.msg_more_x=224;
20705 4 temp_zinit.msg_more_y=64;
20706 4 }
20707
20708 // Okay, let's put these legacy values into itemsbuf.
20709
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 15)
20710
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20711 {
20712
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20713 {
20714 case iFairyStill:
20715 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20716 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20717 9 itemsbuf[i].misc3 = 0;
20718 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20719 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20720 9 break;
20721
20722 case iFairyMoving:
20723 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20724 9 itemsbuf[i].misc2 = moving_fairy_magic;
20725 9 itemsbuf[i].misc3 = 50;
20726 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20727 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20728 9 break;
20729
20730 case iRPotion:
20731 9 itemsbuf[i].misc1 = red_potion_hearts;
20732 9 itemsbuf[i].misc2 = red_potion_magic;
20733 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20734 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20735 9 break;
20736
20737 case iBPotion:
20738 9 itemsbuf[i].misc1 = blue_potion_hearts;
20739 9 itemsbuf[i].misc2 = blue_potion_magic;
20740 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20741 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20742 9 break;
20743
20744 case iSword:
20745 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20746 9 itemsbuf[i].misc1 = beam_hearts[0];
20747 9 itemsbuf[i].misc2 = beam_power[0];
20748 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20749
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20750 9 break;
20751
20752 case iWSword:
20753 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20754 9 itemsbuf[i].misc1 = beam_hearts[1];
20755 9 itemsbuf[i].misc2 = beam_power[1];
20756
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20757 9 break;
20758
20759 case iMSword:
20760 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20761 9 itemsbuf[i].misc1 = beam_hearts[2];
20762 9 itemsbuf[i].misc2 = beam_power[2];
20763
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20764 9 break;
20765
20766 case iXSword:
20767 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20768 9 itemsbuf[i].misc1 = beam_hearts[3];
20769 9 itemsbuf[i].misc2 = beam_power[3];
20770
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20771 9 break;
20772
20773 case iHookshot:
20774 9 itemsbuf[i].misc1 = hookshot_length;
20775 9 itemsbuf[i].misc2 = hookshot_links;
20776 9 break;
20777
20778 case iLongshot:
20779 9 itemsbuf[i].misc1 = longshot_length;
20780 9 itemsbuf[i].misc2 = longshot_links;
20781 9 break;
20782 }
20783 2313 }
20784
20785
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20786 {
20787 //was new subscreen rule
20788
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20789
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20790 4 }
20791
20792
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20793 {
20794 4 temp_zinit.start_dmap=0;
20795 4 }
20796
20797
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20798 {
20799
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20800 4 }
20801
20802
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
108 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20803 {
20804 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20805 temp_zinit.max_rupees=999;
20806 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20807 }
20808
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20809 {
20810 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20811 temp_zinit.max_bombs = 8;
20812 }
20813 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20814 //time to ensure that we port all new values properly:
20815
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(Header->zelda_version < 0x250)
20816 {
20817
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20818 9 }
20819
20820
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 21)
20821 {
20822
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20823 {
20824 return qe_invalid;
20825 }
20826
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20827 {
20828 return qe_invalid;
20829 }
20830
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20831 {
20832 return qe_invalid;
20833 }
20834
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20835 {
20836 return qe_invalid;
20837 }
20838 23 }
20839 else
20840 {
20841 85 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20842 85 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20843 85 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20844 85 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20845 }
20846
20847
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 22)
20848 {
20849
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 23 times.
598 for(int32_t q = 0; q < 25; ++q)
20850 {
20851
2/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
575 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20852 {
20853 return qe_invalid;
20854 }
20855 575 }
20856
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 23 times.
598 for(int32_t q = 0; q < 25; ++q)
20857 {
20858
2/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
575 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20859 {
20860 return qe_invalid;
20861 }
20862 575 }
20863 23 }
20864 else
20865 {
20866
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 85 times.
2210 for(int32_t q = 0; q < 25; ++q)
20867 {
20868 2125 temp_zinit.scrcnt[q] = 0;
20869 2125 temp_zinit.scrmaxcnt[q] = 0;
20870 2125 }
20871 }
20872
20873
20874
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 23)
20875 {
20876
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_type,f,true))
20877 {
20878 return qe_invalid;
20879 }
20880
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_arg,f,true))
20881 {
20882 return qe_invalid;
20883 }
20884
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_percent,f,true))
20885 {
20886 return qe_invalid;
20887 }
20888
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20889 {
20890 return qe_invalid;
20891 }
20892
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20893 {
20894 return qe_invalid;
20895 }
20896 23 }
20897 else
20898 {
20899 85 temp_zinit.dither_type = 0;
20900 85 temp_zinit.dither_arg = 0;
20901 85 temp_zinit.dither_percent = 20;
20902 85 temp_zinit.def_lightrad = 24;
20903 85 temp_zinit.transdark_percent = 0;
20904 }
20905
20906
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 24)
20907 {
20908
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.darkcol,f,true))
20909 {
20910 return qe_invalid;
20911 }
20912 23 }
20913 else
20914 {
20915 85 temp_zinit.darkcol = BLACK;
20916 }
20917
20918
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 25)
20919 {
20920
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.gravity2,f,true))
20921 {
20922 return qe_invalid;
20923 }
20924
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20925 {
20926 return qe_invalid;
20927 }
20928 23 }
20929 else
20930 {
20931 85 temp_zinit.gravity2 = temp_zinit.gravity*100;
20932 85 temp_zinit.swimgravity = 5;
20933 }
20934
20935
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 26)
20936 {
20937
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20938 {
20939 return qe_invalid;
20940 }
20941
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20942 {
20943 return qe_invalid;
20944 }
20945
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20946 {
20947 return qe_invalid;
20948 }
20949 23 }
20950 else
20951 {
20952 85 temp_zinit.heroSideswimUpStep = 150;
20953 85 temp_zinit.heroSideswimSideStep = 100;
20954 85 temp_zinit.heroSideswimDownStep = 75;
20955 }
20956
20957
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 27)
20958 {
20959
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20960 {
20961 return qe_invalid;
20962 }
20963 23 }
20964 else
20965 {
20966 85 temp_zinit.exitWaterJump = 0;
20967 }
20968
20969
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 29)
20970 {
20971
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20972 {
20973 return qe_invalid;
20974 }
20975 23 }
20976 else
20977 {
20978 85 temp_zinit.bunny_ltm = 0;
20979 }
20980
20981
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 30)
20982 {
20983
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20984 {
20985 return qe_invalid;
20986 }
20987 23 }
20988 else
20989 {
20990 85 temp_zinit.switchhookstyle = 1;
20991 }
20992
20993
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 85 times.
108 if(s_version > 31)
20994 {
20995
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20996 {
20997 return qe_invalid;
20998 }
20999 23 }
21000 else
21001 {
21002
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21003
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21004 }
21005
21006
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 temp_zinit.clear_genscript();
21007
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 89 times.
108 if(s_version > 32)
21008 {
21009 19 word numgenscript = 0;
21010
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(!p_igetw(&numgenscript,f,true))
21011 return qe_invalid;
21012
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 for(auto q = 1; q < numgenscript; ++q)
21013 {
21014
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21015 return qe_invalid;
21016
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21017 continue;
21018 1 temp_zinit.gen_doscript[q] = padding&1;
21019
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21020 return qe_invalid;
21021
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21022 return qe_invalid;
21023
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21024
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21025 return qe_invalid;
21026
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21027 return qe_invalid;
21028
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21029 return qe_invalid;
21030
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21031 return qe_invalid;
21032 1 }
21033 19 }
21034
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version > 33)
21035 {
21036
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21037 return qe_invalid;
21038
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21039 return qe_invalid;
21040 9 }
21041
21042
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(keepdata==true)
21043 {
21044
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 zinit = temp_zinit;
21045
21046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(zinit.heroAnimationStyle==las_zelda3slow)
21047 {
21048 hero_animation_speed=2;
21049 }
21050 else
21051 {
21052 108 hero_animation_speed=1;
21053 }
21054 108 }
21055
21056 108 return 0;
21057 432 }
21058
21059 /*
21060 void setupitemdropsets()
21061 {
21062 for(int32_t i=0; i<isMAX; i++)
21063 {
21064 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21065 }
21066 }
21067 */
21068
21069 103 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21070 {
21071 103 build=build; // here to prevent compiler warnings
21072 dword dummy_dword;
21073 103 word item_drop_sets_to_read=0;
21074 item_drop_object tempitemdrop;
21075 103 word s_version=0, s_cversion=0;
21076
21077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(keepdata)
21078 {
21079
2/2
✓ Branch 0 taken 26368 times.
✓ Branch 1 taken 103 times.
26471 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21080 {
21081 26368 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21082 26368 }
21083 103 }
21084
21085
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 4 times.
103 if(version > 0x192)
21086 {
21087 99 item_drop_sets_to_read=0;
21088
21089 //section version info
21090
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
21091 {
21092 return qe_invalid;
21093 }
21094
21095 99 FFCore.quest_format[vItemDropsets] = s_version;
21096
21097 //al_trace("Item drop sets version %d\n", s_version);
21098
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
21099 {
21100 return qe_invalid;
21101 }
21102
21103 //section size
21104
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_dword,f,true))
21105 {
21106 return qe_invalid;
21107 }
21108
21109 //finally... section data
21110
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&item_drop_sets_to_read,f,true))
21111 {
21112 return qe_invalid;
21113 }
21114 99 }
21115 else
21116 {
21117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21118 {
21119 4 init_item_drop_sets();
21120 4 }
21121 }
21122
21123
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 99 times.
103 if(s_version>=1)
21124 {
21125
2/2
✓ Branch 0 taken 1886 times.
✓ Branch 1 taken 99 times.
1985 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21126 {
21127
1/2
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
1886 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21128 {
21129 return qe_invalid;
21130 }
21131
21132
2/2
✓ Branch 0 taken 18860 times.
✓ Branch 1 taken 1886 times.
20746 for(int32_t j=0; j<10; ++j)
21133 {
21134
1/2
✓ Branch 0 taken 18860 times.
✗ Branch 1 not taken.
18860 if(!p_igetw(&tempitemdrop.item[j],f,true))
21135 {
21136 return qe_invalid;
21137 }
21138 18860 }
21139
21140
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 1886 times.
22632 for(int32_t j=0; j<11; ++j)
21141 {
21142
1/2
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
20746 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21143 {
21144 return qe_invalid;
21145 }
21146 20746 }
21147
21148 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21149 // overrides the quest's set #12.
21150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1886 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1886 if(s_version<2 && i==12)
21151 continue;
21152
21153 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21154
1/4
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1886 if(s_version<2) for(int32_t j=0; j<10; ++j)
21155 {
21156 int32_t it = tempitemdrop.item[j];
21157
21158 if((itemsbuf[it].family == itype_rupee
21159 && ((itemsbuf[it].amount)&0xFFF) == 10)
21160 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21161 {
21162 tempitemdrop.chance[j+1]=0;
21163 }
21164 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21165 {
21166 tempitemdrop.chance[j+1]=0;
21167 }
21168
21169 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21170 if(itemsbuf[it].family == itype_misc)
21171 {
21172 // If a non-gameplay item was selected, then item drop was aborted.
21173 // Reflect this by increasing the 'Nothing' chance accordingly.
21174 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21175 tempitemdrop.chance[j+1]=0;
21176 }
21177 }
21178
21179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1886 times.
1886 if(keepdata)
21180 {
21181 1886 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21182 1886 }
21183 1886 }
21184 99 }
21185
21186 103 return 0;
21187 103 }
21188
21189 99 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21190 {
21191 int32_t temp_num;
21192 dword dummy_dword;
21193 word num_favorite_combos;
21194 word num_favorite_combo_aliases;
21195 99 word s_version=0, s_cversion=0;
21196
21197 //section version info
21198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
21199 {
21200 return qe_invalid;
21201 }
21202
21203 99 FFCore.quest_format[vFavourites] = s_version;
21204
21205
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
21206 {
21207 return qe_invalid;
21208 }
21209
21210 //section size
21211
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_dword,f,true))
21212 {
21213 return qe_invalid;
21214 }
21215
21216 99 word per_row = FAVORITECOMBO_PER_ROW;
21217
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
99 if(s_version >= 3)
21218
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&per_row,f,true))
21219 return qe_invalid;
21220 //finally... section data
21221
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&num_favorite_combos,f,true))
21222 {
21223 return qe_invalid;
21224 }
21225
21226 //Hack; port old favorite combos
21227
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
99 if(s_version < 3 && num_favorite_combos == 100)
21228 90 per_row = 13;
21229
21230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
21231 {
21232
2/2
✓ Branch 0 taken 29700 times.
✓ Branch 1 taken 99 times.
29799 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21233 29700 favorite_combos[q] = -1;
21234
2/2
✓ Branch 0 taken 29700 times.
✓ Branch 1 taken 99 times.
29799 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21235 29700 favorite_comboaliases[q] = -1;
21236 99 }
21237
2/2
✓ Branch 0 taken 9449 times.
✓ Branch 1 taken 99 times.
9548 for(int32_t i=0; i<num_favorite_combos; i++)
21238 {
21239
1/2
✓ Branch 0 taken 9449 times.
✗ Branch 1 not taken.
9449 if(!p_igetl(&temp_num,f,true))
21240 {
21241 return qe_invalid;
21242 }
21243
21244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9449 times.
9449 if(keepdata)
21245 {
21246
2/2
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 9000 times.
9449 if(per_row == FAVORITECOMBO_PER_ROW)
21247 449 favorite_combos[i]=temp_num;
21248 else
21249 {
21250 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21251 9000 favorite_combos[new_i]=temp_num;
21252 }
21253 9449 }
21254 9449 }
21255
21256
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21257 {
21258 return qe_invalid;
21259 }
21260
21261
2/2
✓ Branch 0 taken 9000 times.
✓ Branch 1 taken 99 times.
9099 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21262 {
21263
1/2
✓ Branch 0 taken 9000 times.
✗ Branch 1 not taken.
9000 if(!p_igetl(&temp_num,f,true))
21264 {
21265 return qe_invalid;
21266 }
21267
21268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(keepdata)
21269 {
21270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(per_row == FAVORITECOMBO_PER_ROW)
21271 favorite_comboaliases[i]=temp_num;
21272 else
21273 {
21274 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21275 9000 favorite_comboaliases[new_i]=temp_num;
21276 }
21277 9000 }
21278 9000 }
21279
21280 99 word max_combo_cols = 0;
21281 99 word max_mappages = 0;
21282
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
99 if(s_version >= 2)
21283 {
21284
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&max_combo_cols,f,true))
21285 return qe_invalid;
21286 9 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21287
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int q = 0; q < max_combo_cols; ++q)
21288 {
21289
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp,f,true))
21290 return qe_invalid;
21291
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp2,f,true))
21292 return qe_invalid;
21293
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp3,f,true))
21294 return qe_invalid;
21295
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
36 if(keepdata && q < MAX_COMBO_COLS)
21296 {
21297 36 First[q] = tmp;
21298 36 combo_alistpos[q] = tmp2;
21299 36 combo_pool_listpos[q] = tmp3;
21300 36 }
21301 36 }
21302
21303
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&max_mappages,f,true))
21304 return qe_invalid;
21305
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 9 times.
90 for(int q = 0; q < max_mappages; ++q)
21306 {
21307
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetl(&tmp,f,true))
21308 return qe_invalid;
21309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_igetl(&tmp2,f,true))
21310 return qe_invalid;
21311
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && q < MAX_MAPPAGE_BTNS)
21312 {
21313 81 map_page[q].map = tmp;
21314 81 map_page[q].screen = tmp2;
21315 81 }
21316 81 }
21317 9 }
21318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
21319 {
21320
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 99 times.
459 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21321 {
21322 360 First[q] = 0;
21323 360 combo_alistpos[q] = 0;
21324 360 combo_pool_listpos[q] = 0;
21325 360 }
21326
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 99 times.
909 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21327 {
21328 810 map_page[q].map = 0;
21329 810 map_page[q].screen = 0;
21330 810 }
21331 99 }
21332
21333 99 return 0;
21334 99 }
21335
21336 /*
21337 switch (ret) {
21338 case 0:
21339 break;
21340
21341 case qe_invalid:
21342 goto invalid;
21343 break;
21344 default:
21345 pack_fclose(f);
21346 if(!oldquest)
21347 delete_file(tmpfilename);
21348 return ret;
21349 break;
21350 }
21351 */
21352
21353 const char *skip_text[skip_max]=
21354 {
21355 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21356 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21357 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21358 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21359 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21360 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21361 "skip_favorites"
21362 };
21363
21364
21365 void port250QuestRules(){
21366
21367 portCandleRules(); //Candle
21368 portBombRules();
21369
21370 }
21371
21372 void portCandleRules()
21373 {
21374 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21375 //itemdata itemsbuf;
21376 for ( int32_t q = 0; q < MAXITEMS; q++ )
21377 {
21378 if ( itemsbuf[q].family == itype_candle )
21379 {
21380 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21381 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21382 }
21383 }
21384 }
21385
21386 void portBombRules()
21387 {
21388 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21389 //itemdata itemsbuf;
21390 for ( int32_t q = 0; q < MAXITEMS; q++ )
21391 {
21392 if ( itemsbuf[q].family == itype_bomb )
21393 {
21394 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21395 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21396 }
21397 }
21398
21399 }
21400
21401 //Internal function for loadquest wrapper
21402 108 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21403 {
21404 108 DMapEditorLastMaptileUsed = 0;
21405 108 combosread=false;
21406 108 mapsread=false;
21407 108 fixffcs=false;
21408
21409
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21410 {
21411 keepall=false;
21412 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21413 }
21414
21415 // show_progress=true;
21416 char tmpfilename[L_tmpnam];
21417 108 temp_name(tmpfilename);
21418 // char percent_done[30];
21419 108 bool catchup=false;
21420 byte tempbyte;
21421 108 word old_map_count=map_count;
21422
21423 108 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21424 108 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21425 108 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21426
21427
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall==false||get_bit(skip_flags, skip_rules))
21428 {
21429 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21430 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21431 }
21432
21433 108 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21434 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21435
21436
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall==false||get_bit(skip_flags, skip_midis))
21437 {
21438 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21439 }
21440
21441
21442
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21443 {
21444 108 zScript.clear();
21445 108 globalmap.clear();
21446 108 genericmap.clear();
21447 108 ffcmap.clear();
21448 108 itemmap.clear();
21449 108 npcmap.clear();
21450 108 ewpnmap.clear();
21451 108 lwpnmap.clear();
21452 108 playermap.clear();
21453 108 dmapmap.clear();
21454 108 screenmap.clear();
21455 108 itemspritemap.clear();
21456 108 comboscriptmap.clear();
21457
21458
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21459 {
21460 55188 ffcmap[i].clear();
21461 55188 }
21462
21463 108 globalmap[0].slotname = "Slot 1:";
21464 108 globalmap[0].scriptname = "~Init";
21465 108 globalmap[0].update();
21466
21467
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 108 times.
864 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21468 {
21469 756 globalmap[i].clear();
21470 756 }
21471
21472
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21473 {
21474 27540 itemmap[i].clear();
21475 27540 }
21476
21477 //new script types -- prevent carrying over to a quest that you load after reading them
21478 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21479
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21480 {
21481 27540 npcmap[i].clear();
21482 27540 }
21483
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21484 {
21485 27540 lwpnmap[i].clear();
21486 27540 }
21487
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21488 {
21489 27540 ewpnmap[i].clear();
21490 27540 }
21491
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 108 times.
540 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21492 {
21493 432 playermap[i].clear();
21494 432 }
21495
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21496 {
21497 27540 dmapmap[i].clear();
21498 27540 }
21499
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21500 {
21501 27540 screenmap[i].clear();
21502 27540 }
21503
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21504 {
21505 27540 itemspritemap[i].clear();
21506 27540 }
21507
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21508 {
21509 55188 comboscriptmap[i].clear();
21510 55188 }
21511
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21512 {
21513 55188 genericmap[i].clear();
21514 55188 }
21515
21516 108 reset_scripts();
21517 108 }
21518
21519 zquestheader tempheader;
21520 108 memset(&tempheader, 0, sizeof(zquestheader));
21521 108 zinfo tempzi;
21522 108 tempzi.clear();
21523 108 load_tmp_zi = &tempzi;
21524
21525 // oldquest flag is set when an unencrypted qst file is suspected.
21526 108 bool oldquest = false;
21527 108 int32_t open_error=0;
21528 108 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21529
21530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!f)
21531 return open_error;
21532 char zinfofilename[2048];
21533 108 replace_extension(zinfofilename, filename, "zinfo", 2047);
21534 108 int32_t ret=0;
21535
21536 //header
21537 108 box_out("Reading Header...");
21538 108 ret=readheader(f, &tempheader, true, printmetadata);
21539
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
108 checkstatus(ret);
21540 108 box_out("okay.");
21541 108 box_eol();
21542
21543
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 23 times.
108 if(read_zinfo)
21544 {
21545 23 box_out("Reading ZInfo - ");
21546
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 box_out(read_ext_zinfo ? "External..." : "Internal...");
21547
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(read_ext_zinfo)
21548 {
21549 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21550 1 ret=readzinfo(inf, tempzi, tempheader);
21551
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21552
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21553 1 }
21554 else
21555 {
21556 22 ret=readzinfo(f, tempzi, tempheader);
21557
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
22 checkstatus(ret);
21558 }
21559 23 box_out("okay.");
21560 23 box_eol();
21561 23 }
21562
21563
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(tempheader.zelda_version>=0x193)
21564 {
21565 dword section_id;
21566
21567 //section id
21568
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_mgetl(&section_id,f,true))
21569 {
21570 return qe_invalid;
21571 }
21572
21573
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 104 times.
2555 while(!pack_feof(f))
21574 {
21575
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 104 times.
✓ Branch 6 taken 99 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 104 times.
✓ Branch 9 taken 104 times.
✓ Branch 10 taken 104 times.
✓ Branch 11 taken 104 times.
✓ Branch 12 taken 104 times.
✓ Branch 13 taken 99 times.
✓ Branch 14 taken 99 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 104 times.
✓ Branch 17 taken 99 times.
✓ Branch 18 taken 99 times.
✓ Branch 19 taken 99 times.
✓ Branch 20 taken 99 times.
✓ Branch 21 taken 104 times.
✓ Branch 22 taken 104 times.
✓ Branch 23 taken 99 times.
✓ Branch 24 taken 99 times.
2451 switch(section_id)
21576 {
21577 case ID_RULES:
21578
21579 //rules
21580
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21581 {
21582 box_out("found.");
21583 box_eol();
21584 catchup=false;
21585 }
21586
21587 104 box_out("Reading Rules...");
21588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21589
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21590 104 box_out("okay.");
21591 104 box_eol();
21592 104 break;
21593
21594 case ID_STRINGS:
21595
21596 //strings
21597
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21598 {
21599 box_out("found.");
21600 box_eol();
21601 catchup=false;
21602 }
21603
21604 104 box_out("Reading Strings...");
21605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21606
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21607 104 box_out("okay.");
21608 104 box_eol();
21609 104 break;
21610
21611 case ID_MISC:
21612
21613 //misc data
21614
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21615 {
21616 box_out("found.");
21617 box_eol();
21618 catchup=false;
21619 }
21620
21621 104 box_out("Reading Misc. Data...");
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21623
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21624 104 box_out("okay.");
21625 104 box_eol();
21626 104 break;
21627
21628 case ID_TILES:
21629
21630 //tiles
21631
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21632 {
21633 box_out("found.");
21634 box_eol();
21635 catchup=false;
21636 }
21637
21638 104 box_out("Reading Tiles...");
21639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21640
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21641 104 box_out("okay.");
21642 104 box_eol();
21643 104 break;
21644
21645 case ID_COMBOS:
21646
21647 //combos
21648
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21649 {
21650 box_out("found.");
21651 box_eol();
21652 catchup=false;
21653 }
21654
21655 104 box_out("Reading Combos...");
21656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21657 104 combosread=true;
21658
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21659 104 box_out("okay.");
21660 104 box_eol();
21661 104 break;
21662
21663 case ID_COMBOALIASES:
21664
21665 //combo aliases
21666
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21667 {
21668 box_out("found.");
21669 box_eol();
21670 catchup=false;
21671 }
21672
21673 99 box_out("Reading Combo Aliases...");
21674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21675
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21676 99 box_out("okay.");
21677 99 box_eol();
21678 99 break;
21679
21680 case ID_CSETS:
21681
21682 //color data
21683
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21684 {
21685 box_out("found.");
21686 box_eol();
21687 catchup=false;
21688 }
21689
21690 104 box_out("Reading Color Data...");
21691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21692
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21693 104 box_out("okay.");
21694 104 box_eol();
21695 104 break;
21696
21697 case ID_MAPS:
21698
21699 //maps
21700
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21701 {
21702 box_out("found.");
21703 box_eol();
21704 catchup=false;
21705 }
21706
21707 104 box_out("Reading Maps...");
21708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21709 104 mapsread=true;
21710
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21711 104 box_out("okay.");
21712 104 box_eol();
21713 104 break;
21714
21715 case ID_DMAPS:
21716
21717 //dmaps
21718
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21719 {
21720 box_out("found.");
21721 box_eol();
21722 catchup=false;
21723 }
21724
21725 104 box_out("Reading DMaps...");
21726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21727
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21728 104 box_out("okay.");
21729 104 box_eol();
21730 104 break;
21731
21732 case ID_DOORS:
21733
21734 //door combo sets
21735
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21736 {
21737 box_out("found.");
21738 box_eol();
21739 catchup=false;
21740 }
21741
21742 104 box_out("Reading Doors...");
21743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21744
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21745 104 box_out("okay.");
21746 104 box_eol();
21747 104 break;
21748
21749 case ID_ITEMS:
21750
21751 //items
21752
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21753 {
21754 box_out("found.");
21755 box_eol();
21756 catchup=false;
21757 }
21758
21759 104 box_out("Reading Items...");
21760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21761
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21762
21763 104 box_out("okay.");
21764 104 box_eol();
21765 104 break;
21766
21767 case ID_WEAPONS:
21768
21769 //weapons
21770
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21771 {
21772 box_out("found.");
21773 box_eol();
21774 catchup=false;
21775 }
21776
21777 104 box_out("Reading Weapons...");
21778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21779
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21780 104 box_out("okay.");
21781 104 box_eol();
21782 104 break;
21783
21784 case ID_COLORS:
21785
21786 //misc. colors
21787
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21788 {
21789 box_out("found.");
21790 box_eol();
21791 catchup=false;
21792 }
21793
21794 99 box_out("Reading Misc. Colors...");
21795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21796
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21797 99 box_out("okay.");
21798 99 box_eol();
21799 99 break;
21800
21801 case ID_ICONS:
21802
21803 //game icons
21804
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21805 {
21806 box_out("found.");
21807 box_eol();
21808 catchup=false;
21809 }
21810
21811 99 box_out("Reading Game Icons...");
21812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21813
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21814 99 box_out("okay.");
21815 99 box_eol();
21816 99 break;
21817
21818 case ID_INITDATA:
21819
21820 //initialization data
21821
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21822 {
21823 box_out("found.");
21824 box_eol();
21825 catchup=false;
21826 }
21827
21828 104 box_out("Reading Init. Data...");
21829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21830
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21831 104 box_out("okay.");
21832 104 box_eol();
21833
21834
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21835 {
21836
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 19 times.
104 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21837 {
21838 19 setupsubscreens();
21839
21840
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19 times.
9747 for(int32_t i=0; i<MAXDMAPS; ++i)
21841 {
21842 9728 int32_t type=DMaps[i].type&dmfTYPE;
21843
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 9634 times.
9728 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21844 9728 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21845 9728 }
21846 19 }
21847 104 }
21848
21849
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_sfx))
21850 {
21851 104 setupsfx();
21852 104 }
21853
21854
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21855 {
21856 104 init_item_drop_sets();
21857 104 }
21858
21859
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_favorites))
21860 {
21861 104 init_favorites();
21862 104 }
21863
21864 104 break;
21865
21866 case ID_GUYS:
21867
21868 //guys
21869
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21870 {
21871 box_out("found.");
21872 box_eol();
21873 catchup=false;
21874 }
21875
21876 104 box_out("Reading Custom Guy Data...");
21877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21878
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21879 104 box_out("okay.");
21880 104 box_eol();
21881 104 break;
21882
21883 case ID_HEROSPRITES:
21884
21885 //player sprites
21886
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21887 {
21888 box_out("found.");
21889 box_eol();
21890 catchup=false;
21891 }
21892
21893 99 box_out("Reading Custom Player Sprite Data...");
21894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21895
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21896 99 box_out("okay.");
21897 99 box_eol();
21898 99 break;
21899
21900 case ID_SUBSCREEN:
21901
21902 //custom subscreens
21903
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21904 {
21905 box_out("found.");
21906 box_eol();
21907 catchup=false;
21908 }
21909
21910 99 box_out("Reading Custom Subscreen Data...");
21911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21912
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21913 99 box_out("okay.");
21914 99 box_eol();
21915 99 break;
21916
21917 case ID_FFSCRIPT:
21918
21919 //Freeform combo scripts
21920
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21921 {
21922 box_out("found.");
21923 box_eol();
21924 catchup=false;
21925 }
21926
21927 99 box_out("Reading FF Script Data...");
21928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21929
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21930 99 box_out("okay.");
21931 99 box_eol();
21932 99 break;
21933
21934 case ID_SFX:
21935
21936 //SFX data
21937
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21938 {
21939 box_out("found.");
21940 box_eol();
21941 catchup=false;
21942 }
21943
21944 99 box_out("Reading SFX Data...");
21945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21946
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21947 99 box_out("okay.");
21948 99 box_eol();
21949 99 break;
21950
21951 case ID_MIDIS:
21952
21953 //midis
21954
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21955 {
21956 box_out("found.");
21957 box_eol();
21958 catchup=false;
21959 }
21960
21961 104 box_out("Reading Tunes...");
21962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21963
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21964 104 box_out("okay.");
21965 104 box_eol();
21966 104 break;
21967
21968 case ID_CHEATS:
21969
21970 //cheat codes
21971
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21972 {
21973 box_out("found.");
21974 box_eol();
21975 catchup=false;
21976 }
21977
21978 104 box_out("Reading Cheat Codes...");
21979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21980
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21981 104 box_out("okay.");
21982 104 box_eol();
21983 104 break;
21984
21985 case ID_ITEMDROPSETS:
21986
21987 //item drop sets
21988
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21989 {
21990 box_out("found.");
21991 box_eol();
21992 catchup=false;
21993 }
21994
21995 99 box_out("Reading Item Drop Sets...");
21996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21997
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21998 99 box_out("okay.");
21999 99 box_eol();
22000 99 break;
22001
22002 case ID_FAVORITES:
22003
22004 //favorite combos and combo aliases
22005
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
22006 {
22007 box_out("found.");
22008 box_eol();
22009 catchup=false;
22010 }
22011
22012 99 box_out("Reading Favorite Combos...");
22013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
22014
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
22015 99 box_out("okay.");
22016 99 box_eol();
22017 99 break;
22018
22019 default:
22020 if(!catchup)
22021 {
22022 box_out("Bad token! Searching...");
22023 box_eol();
22024 }
22025
22026 catchup=true;
22027 break;
22028 }
22029
22030
22031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2451 times.
2451 if(catchup)
22032 {
22033 //section id
22034 section_id=(section_id<<8);
22035
22036 if(!p_getc(&tempbyte,f,true))
22037 {
22038 return qe_invalid;
22039 }
22040
22041 section_id+=tempbyte;
22042 }
22043
22044 else
22045 {
22046 //section id
22047
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 2347 times.
2451 if(!pack_feof(f))
22048 {
22049
1/2
✓ Branch 0 taken 2347 times.
✗ Branch 1 not taken.
2347 if(!p_mgetl(&section_id,f,true))
22050 {
22051 return qe_invalid;
22052 }
22053 2347 }
22054 }
22055 }
22056 104 }
22057 else
22058 {
22059 //rules
22060 4 box_out("Reading Rules...");
22061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22062
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22063 4 box_out("okay.");
22064 4 box_eol();
22065
22066 //strings
22067 4 box_out("Reading Strings...");
22068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22069
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22070 4 box_out("okay.");
22071 4 box_eol();
22072
22073 //door combo sets
22074 4 box_out("Reading Doors...");
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22076
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22077 4 box_out("okay.");
22078 4 box_eol();
22079
22080 //dmaps
22081 4 box_out("Reading DMaps...");
22082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22083
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22084 4 box_out("okay.");
22085 4 box_eol();
22086
22087 // misc data
22088 4 box_out("Reading Misc. Data...");
22089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22090
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22091 4 box_out("okay.");
22092 4 box_eol();
22093
22094 //items
22095 4 box_out("Reading Items...");
22096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22097
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22098 4 box_out("okay.");
22099 4 box_eol();
22100
22101 //weapons
22102 4 box_out("Reading Weapons...");
22103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22104
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22105 4 box_out("okay.");
22106 4 box_eol();
22107
22108 //guys
22109 4 box_out("Reading Custom Guy Data...");
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22111
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22112 4 box_out("okay.");
22113 4 box_eol();
22114
22115 //maps
22116 4 box_out("Reading Maps...");
22117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22118 4 mapsread=true;
22119
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22120 4 box_out("okay.");
22121 4 box_eol();
22122
22123 //combos
22124 4 box_out("Reading Combos...");
22125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22126 4 combosread=true;
22127
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22128 4 box_out("okay.");
22129 4 box_eol();
22130
22131 //color data
22132 4 box_out("Reading Color Data...");
22133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22134
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22135 4 box_out("okay.");
22136 4 box_eol();
22137
22138 //tiles
22139 4 box_out("Reading Tiles...");
22140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22141
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22142 4 box_out("okay.");
22143 4 box_eol();
22144
22145 //midis
22146 4 box_out("Reading Tunes...");
22147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22148
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22149 4 box_out("okay.");
22150 4 box_eol();
22151
22152 //cheat codes
22153 4 box_out("Reading Cheat Codes...");
22154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22155
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22156 4 box_out("okay.");
22157 4 box_eol();
22158
22159 //initialization data
22160 4 box_out("Reading Init. Data...");
22161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22162
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22163 4 box_out("okay.");
22164 4 box_eol();
22165
22166
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22167 {
22168 4 setupsubscreens();
22169
22170
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22171 {
22172 2048 int32_t type=DMaps[i].type&dmfTYPE;
22173
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22174 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22175 2048 }
22176 4 }
22177
22178 4 box_out("Setting Up Default Sound Effects...");
22179
22180
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22181 4 setupsfx();
22182
22183 4 box_out("okay.");
22184 4 box_eol();
22185
22186 //player sprites
22187 4 box_out("Reading Custom Player Sprite Data...");
22188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22189
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22190 4 box_out("okay.");
22191 4 box_eol();
22192
22193 4 box_out("Setting Up Default Item Drop Sets...");
22194
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22195 4 box_out("okay.");
22196 4 box_eol();
22197 }
22198
22199 108 init_spritelists();
22200
22201 // check data
22202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(f)
22203 {
22204 108 pack_fclose(f);
22205 108 }
22206 108 clear_quest_tmpfile();
22207
22208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!oldquest)
22209 {
22210
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(exists(tmpfilename))
22211 {
22212 delete_file(tmpfilename);
22213 }
22214 108 }
22215
22216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(fixffcs && combosread && mapsread)
22217 {
22218 for(int32_t i=0; i<map_count; i++)
22219 {
22220 for(int32_t j=0; j<MAPSCRS; j++)
22221 {
22222 for(int32_t m=0; m<32; m++)
22223 {
22224 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22225 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22226 }
22227 }
22228 }
22229 }
22230
22231
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 22 times.
108 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22232 {
22233 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22234 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22235 22 zinit.cont_heart=100;
22236 22 zinit.start_heart=zinit.hc;
22237 22 }
22238
22239 108 box_out("Done.");
22240 108 box_eol();
22241 108 box_end(false);
22242
22243 // if (keepall==true||!get_bit(skip_flags, skip_header))
22244
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_header))
22245 {
22246 108 memcpy(Header, &tempheader, sizeof(tempheader));
22247 108 }
22248
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22249 {
22250 108 ZI.copyFrom(tempzi);
22251 108 }
22252
22253
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_maps))
22254 {
22255 map_count=old_map_count;
22256 }
22257
22258
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_rules))
22259 {
22260 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22261 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22262 }
22263
22264
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_midis))
22265 {
22266 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22267 }
22268
22269 //Debug FFCore.quest_format[]
22270 108 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22271 108 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22272 108 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22273 108 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22274 108 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22275 108 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22276 108 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22277 108 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22278 108 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22279 108 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22280 108 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22281 108 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22282 108 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22283 108 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22284 108 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22285 108 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22286 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22287 108 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22288 108 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22289 108 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22290 108 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22291 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22292 108 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22293 108 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22294 108 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22295 108 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22296 108 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22297 108 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22298 108 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22299 108 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22300 //Print metadata for versions under 2.10 here. Bleah.
22301
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if( FFCore.quest_format[vZelda] < 0x210 )
22302 {
22303 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22304
22305
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22306 {
22307 case 0x193:
22308 {
22309 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22310 }
22311 case 0x192:
22312 {
22313 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22314 }
22315 case 0x190:
22316 {
22317 4 zprint2("Last saved in ZC Editor Version: 1.90");
22318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22319 4 else zprint2("\n");
22320 4 break;
22321 }
22322 case 0x188:
22323 {
22324 zprint2("Last saved in ZC Editor Version: 1.88");
22325 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22326 else zprint2("\n");
22327 break;
22328 }
22329 case 0x187:
22330 {
22331 zprint2("Last saved in ZC Editor Version: 1.87");
22332 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22333 else zprint2("\n");
22334 break;
22335 }
22336 case 0x186:
22337 {
22338 zprint2("Last saved in ZC Editor Version: 1.86");
22339 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22340 else zprint2("\n");
22341 break;
22342 }
22343 case 0x185:
22344 {
22345 zprint2("Last saved in ZC Editor Version: 1.85");
22346 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22347 else zprint2("\n");
22348 break;
22349 }
22350 case 0x184:
22351 {
22352 zprint2("Last saved in ZC Editor Version: 1.84");
22353 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22354 else zprint2("\n");
22355 break;
22356 }
22357 case 0x183:
22358 {
22359 zprint2("Last saved in ZC Editor Version: 1.83");
22360 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22361 else zprint2("\n");
22362 break;
22363 }
22364 case 0x182:
22365 {
22366 zprint2("Last saved in ZC Editor Version: 1.82");
22367 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22368 else zprint2("\n");
22369 break;
22370 }
22371 case 0x181:
22372 {
22373 zprint2("Last saved in ZC Editor Version: 1.81");
22374 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22375 else zprint2("\n");
22376 break;
22377 }
22378 case 0x180:
22379 {
22380 zprint2("Last saved in ZC Editor Version: 1.80");
22381 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22382 else zprint2("\n");
22383 break;
22384 }
22385 default:
22386 {
22387 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22388 }
22389 }
22390 4 }
22391
22392 108 return qe_OK;
22393
22394 invalid:
22395 box_out("error.");
22396 box_eol();
22397 box_end(true);
22398
22399 if(f)
22400 {
22401 pack_fclose(f);
22402 }
22403
22404 if(!oldquest)
22405 {
22406 if(exists(tmpfilename))
22407 {
22408 delete_file(tmpfilename);
22409 }
22410 }
22411
22412 return qe_invalid;
22413
22414 108 }
22415
22416 108 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22417 {
22418 108 loading_qst_name = filename;
22419 108 loading_qst_num = qst_num;
22420 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22421 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22422
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if (!is_ci())
22423 loadquest_report = report;
22424 108 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22425 108 load_tmp_zi = NULL;
22426 108 loading_qst_name = NULL;
22427 108 loadquest_report = false;
22428 108 loading_qst_num = 0;
22429 108 return ret;
22430 }
22431